Skip to content
This repository was archived by the owner on Nov 3, 2023. It is now read-only.

Conversation

@eric-wieser
Copy link
Owner

@eric-wieser eric-wieser commented Aug 26, 2016

So that you can update without needing pastebin any more

Instead of creating github.rom, this creates a _build directory inside wherever you downloaded the script to, within which it places copies of apis and programs with their dofiles rewritten.

@aaronmallen, can I get you to test this?

if status then
makeFile(path, response)
else
printError(('Unable to download %s'):format(path))
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line would never actually be hit before anyway!

@eric-wieser eric-wieser force-pushed the separate-install-download branch from 499d311 to 996dff6 Compare August 26, 2016 06:21
install Outdated

for _, prog in pairs(fs.list('programs')) do
local f = fs.open('/'..prog, 'w')
f.write([[loadfile('%s', getfenv())()]]:format(dest_dir..'/programs/'..prog))
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turns out loadfile takes an env as an argument, so this becomes a simple one-liner

-- Easy installer. Bootstrapped by http://pastebin.com/p8PJVxC4

local base_url, dest = select(1,...)
dest = dest or 'computercraft-github'
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps cc-git-src would be better here?

Copy link
Contributor

@aaronmallen aaronmallen Oct 28, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What you're essentially creating here is a custom rom... I think the best default would be github.rom.

@aaronmallen
Copy link
Contributor

aaronmallen commented Aug 26, 2016

doesn't work. I think the problem is with your pastebin script:

> pastebin run zDAQHQdz seperate-install-download
Connecting to pastebin.com... Success.
ZDAQHQdz:9: bad argument: String expected, got table
>

also if you register for a pastebin account, and create the paste under your account you can edit it and what not and not have to update the pasetbin id here in the project.

@eric-wieser
Copy link
Owner Author

eric-wieser commented Aug 26, 2016

Yep, should be:

-- Easy Installer for computercraft-github by Eric Wieser
-- https://github.com/eric-wieser/computercraft-github
local tree = select(1,...) or 'master'
local url = ('https://raw.githubusercontent.com/eric-wieser/computercraft-github/%s'):format(tree)
local response = http.get(url..'/bootstrap.lua').readAll()
setfenv(loadstring(response, 'bootstrap.lua'), getfenv())(url)

loadstring doesn't take an env, unlike loadfile. Maybe I don't need the env anyway?

@aaronmallen
Copy link
Contributor

I didn't

On Fri, Aug 26, 2016, 18:31 Eric Wieser notifications@github.com wrote:

Yep, should be:

-- Easy Installer for computercraft-github by Eric Wieser
-- https://github.com/eric-wieser/computercraft-github
local tree = select(1,...)
if not tree then
tree = 'master'
end
local url = ('https://raw.githubusercontent.com/eric-wieser/computercraft-github/%s'):format(tree)
local response = http.get(url..'/bootstrap.lua').readAll()
setfenv(loadstring(response, 'bootstrap.lua'), getfenv())(url)

loadstring doesn't take an env, unlike loadfile. Maybe I don't need the
env anyway?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#12 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AA41Fh7YnsbigVbwm2Krok9hQcsIb_wxks5qj3drgaJpZM4Jtxdg
.

@aaronmallen
Copy link
Contributor

@mention me when your ready for another test.

On Fri, Aug 26, 2016, 20:13 Aaron Allen aaronmallen4@gmail.com wrote:

I didn't

On Fri, Aug 26, 2016, 18:31 Eric Wieser notifications@github.com wrote:

Yep, should be:

-- Easy Installer for computercraft-github by Eric Wieser
-- https://github.com/eric-wieser/computercraft-github
local tree = select(1,...)
if not tree then
tree = 'master'
end
local url = ('https://raw.githubusercontent.com/eric-wieser/computercraft-github/%s'):format(tree)
local response = http.get(url..'/bootstrap.lua').readAll()
setfenv(loadstring(response, 'bootstrap.lua'), getfenv())(url)

loadstring doesn't take an env, unlike loadfile. Maybe I don't need the
env anyway?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#12 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AA41Fh7YnsbigVbwm2Krok9hQcsIb_wxks5qj3drgaJpZM4Jtxdg
.

@eric-wieser
Copy link
Owner Author

@aaronmallen
Copy link
Contributor

> pastebin run 4avPU6Cz seperate-install-download
Connecting to pastebin.com... Success.
Unable to download apis/dkjson

@eric-wieser
Copy link
Owner Author

@aaronmallen: How about now?

@aaronmallen
Copy link
Contributor

attempt to index a nil value line 5 of the pastebin

@eric-wieser
Copy link
Owner Author

eric-wieser commented Aug 27, 2016

The pastebin didn't change? I think you got unlucky, and the http request failed

@aaronmallen
Copy link
Contributor

well then Im continually getting unlucky... its happened about 6 times now :) you could always load up an instance of CC and test away...

@eric-wieser
Copy link
Owner Author

eric-wieser commented Aug 27, 2016

Yeah, I didn't really want to have to do that, but I guess I ought to.

I just updated it with an assertion. It sounds like the http api is missing for you?

Does it give different output now?

@aaronmallen
Copy link
Contributor

no it looks like Ive reached the gh api limit...

4avPU6Cz:5: Could not connect to github

@eric-wieser
Copy link
Owner Author

Then yes, I'd say go ahead with trying to make auth work!

@aaronmallen
Copy link
Contributor

would be nice to have #11 merged before working on that.

@aaronmallen aaronmallen mentioned this pull request Oct 28, 2016
}

local function request(url_path)
local request = http.get(base_url..'/'..url_path)
Copy link
Contributor

@aaronmallen aaronmallen Oct 28, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't work as expected. For some reason if request fails CC is making request = nil. We should mimic what we did in the getAPI method:

local request = http.get(base_url..'/'..url_path)
local success = false
local response = nil
if request then
  success = request.getResponseCode() == 200
  response = request.readAll()
  request.close()
end
return success, response

end
status, response = request(path)
try = try + 1
until status ~= 200
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you use my recommended change above this would need to be

until status

w.close()
end

for _, folder in ipairs({'api', 'programs'})
Copy link
Contributor

@aaronmallen aaronmallen Oct 28, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this would be better served as a table like what we do with FILES instead of hardcoded here.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants