This repository has been archived by the owner on Mar 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* new bootstrap 🐿 v2.10.3 * refactor docs 🐿 v2.10.3 * tpyo 🐿 v2.10.3 * refactor commands to use yargs more 🐿 v2.10.3 * add update-bootstrap command 🐿 v2.10.3 * wait wait wait it has 𝒕𝒆𝒔𝒕𝒔 🐿 v2.10.3 * add update-bootstrap target, document command 🐿 v2.10.3 * add link
- Loading branch information
1 parent
be27062
commit 02ad5d4
Showing
7 changed files
with
180 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
exports.command = 'bootstrap'; | ||
exports.describe = 'called by makefiles to include n-gage'; | ||
exports.handler = () => { | ||
console.log(require.resolve('../index.mk')); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
const fs = require('fs'); | ||
|
||
exports.command = 'update-bootstrap <makefile>'; | ||
exports.describe = 'migrate a makefile from bootstrap v1 to v2'; | ||
|
||
const oldBootstrap = `node_modules/@financial-times/n-gage/index.mk: | ||
npm install --no-save --no-package-lock @financial-times/n-gage | ||
touch $@ | ||
-include node_modules/@financial-times/n-gage/index.mk`; | ||
|
||
const newBootstrap = 'include $(shell npx -p @financial-times/n-gage ngage bootstrap)'; | ||
|
||
const twee = 'have a nice day! xoxoxox'; | ||
|
||
exports.handler = argv => { | ||
let content; | ||
|
||
try { | ||
content = fs.readFileSync(argv.makefile, 'utf8'); | ||
} catch(e) { | ||
// probably the file doesn't exist. this shouldn't happen unless someone runs `ngage update-bootstrap nonexistent/Makefile` | ||
console.log(`yeah we couldn't read from ${argv.makefile}, make sure that's a real thing`); | ||
throw e; | ||
} | ||
|
||
const replaced = content.replace(oldBootstrap, newBootstrap); | ||
|
||
if(replaced === content) { | ||
console.log( | ||
`looks like your makefile isn't using the standard n-gage v1 bootstrap, or it's already been migrated to v2. have a look at ${argv.makefile}, and if there's something that looks like: | ||
${oldBootstrap} | ||
please replace it with: | ||
${newBootstrap} | ||
${twee}`); | ||
|
||
return; | ||
} | ||
|
||
try { | ||
fs.writeFileSync(argv.makefile, replaced, 'utf8'); | ||
} catch(e) { | ||
console.log(`yeah we couldn't write to ${argv.makefile}, dunno what's up with that, sorry,`); | ||
throw e; | ||
} | ||
|
||
console.log( | ||
`bootstrap updated to v2! check that ${argv.makefile} looks good and commit it plz | ||
${twee}`); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
#!/usr/bin/env node | ||
|
||
if (process.argv.length > 1 && process.argv[2] === 'get-config') { | ||
require('./get-config')(); | ||
} else { | ||
console.log('ngage get-config --help'); | ||
} | ||
require('yargs') | ||
.commandDir('commands') | ||
.demandCommand() | ||
.help() | ||
.argv; |
Oops, something went wrong.