Skip to content

Commit f7f893b

Browse files
committed
Deploy readme.md
1 parent be11dd0 commit f7f893b

File tree

3 files changed

+34
-19
lines changed

3 files changed

+34
-19
lines changed

commands/deploy.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ const utils = require('../utils/utils');
88
const pjsonPath = path.join(process.cwd(), 'package.json');
99
const pjson = utils.fileExists(pjsonPath) ? require(pjsonPath) : {};
1010

11+
const readmePath = path.join(process.cwd(), 'readme.md');
12+
1113
const zipDir = path.join(__dirname, '../data/output.zip');
1214

1315
module.exports.run = () => {
@@ -28,6 +30,11 @@ module.exports.run = () => {
2830

2931
console.log('Converting to travel size...');
3032

33+
let readme;
34+
if (utils.fileExists(readmePath)) {
35+
readme = fs.readFileSync(readmePath, 'utf8');
36+
}
37+
3138
// listen for all archive data to be written
3239
output.on('close', () => {
3340
console.log('Flying up to the cloud...');
@@ -42,6 +49,11 @@ module.exports.run = () => {
4249
if (pjson.author) {
4350
form.append('team', pjson.author);
4451
}
52+
53+
if (readme) {
54+
form.append('readme', readme);
55+
}
56+
4557
form.append('entrypoint', pjson.main);
4658
form.append('version', response.version);
4759
form.append('name', pjson.name);

commands/init.js

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -44,24 +44,27 @@ module.exports.run = () => {
4444
fs.readFile(path.join(__dirname, '../utils/stub.js'), 'utf8', (err, data) => {
4545
const stub = data.replace('<<action>>', answers.action);
4646

47-
fs.writeFile(`${answers.name}.js`, stub, () => {
48-
const packageJson = {
49-
name: answers.name,
50-
version: answers.version,
51-
main: `${answers.name}.js`,
52-
private: answers.internal === 'private',
53-
dependencies: {
54-
'api-build': 'latest',
55-
},
56-
};
47+
fs.writeFileSync(`${answers.name}.js`, stub);
5748

58-
fs.writeFile('package.json', JSON.stringify(packageJson, undefined, 2), () => {
59-
console.log(`Running ${'npm install'.yellow}...`);
60-
exec('npm install', () => {
61-
const filename = `${answers.name}.js`;
62-
console.log(`\nGreat! We've created it! Just edit ${filename.yellow} and type ${'api deploy'.yellow} when you are ready!\n`);
63-
});
64-
});
49+
const packageJson = {
50+
name: answers.name,
51+
version: answers.version,
52+
main: `${answers.name}.js`,
53+
private: answers.internal === 'private',
54+
dependencies: {
55+
'api-build': 'latest',
56+
},
57+
};
58+
59+
const README = `Welcome to ${answers.name}!`;
60+
fs.writeFileSync('readme.md', README);
61+
62+
fs.writeFileSync('package.json', JSON.stringify(packageJson, undefined, 2));
63+
64+
console.log(`Running ${'npm install'.yellow}...`);
65+
exec('npm install', () => {
66+
const filename = `${answers.name}.js`;
67+
console.log(`\nGreat! We've created it! Just edit ${filename.yellow} and type ${'api deploy'.yellow} when you are ready!\n`);
6568
});
6669
});
6770
});

utils/utils.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ const CookieJar = require('tough-cookie').CookieJar;
88

99
exports.credPath = path.join(__dirname, '..', 'data/creds.json');
1010

11-
exports.BUILD_URL = 'http://staging.bips.tech';
12-
// exports.BUILD_URL = 'http://localhost:5000';
11+
// exports.BUILD_URL = 'http://staging.bips.tech';
12+
exports.BUILD_URL = 'http://localhost:5000';
1313

1414
exports.fileExists = (file) => {
1515
try {

0 commit comments

Comments
 (0)