@tgcloud/create-bot 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/index.js +12 -10
- package/package.json +1 -1
package/bin/index.js
CHANGED
|
@@ -40,8 +40,15 @@ async function main() {
|
|
|
40
40
|
const noGit = args.includes('--no-git');
|
|
41
41
|
const target = args.find((a) => !a.startsWith('-'));
|
|
42
42
|
|
|
43
|
+
// One flag telling every delegated `tgcloud` call it runs under the create-bot
|
|
44
|
+
// bootstrap. Set once here and inherited by all child processes (execSync
|
|
45
|
+
// inherits process.env), so commands can tailor their output for this path.
|
|
46
|
+
process.env.TGCLOUD_VIA_CREATE = '1';
|
|
47
|
+
|
|
43
48
|
if (!target) {
|
|
44
|
-
|
|
49
|
+
// `--` before --no-git is required with `npm create`: npm intercepts flags
|
|
50
|
+
// before it, so a bare `--no-git` is swallowed and git init still runs.
|
|
51
|
+
fail('Usage: npm create @tgcloud/bot <directory> [-- --no-git]');
|
|
45
52
|
}
|
|
46
53
|
|
|
47
54
|
// The argument is a directory path — a bare name (→ ./name), "." (current folder),
|
|
@@ -83,10 +90,6 @@ async function main() {
|
|
|
83
90
|
execSync('npx tgcloud init' + (noGit ? ' --no-git' : ''), {
|
|
84
91
|
cwd: targetDir,
|
|
85
92
|
stdio: 'inherit',
|
|
86
|
-
// create-bot owns the final "Next steps" — it alone knows the cd target,
|
|
87
|
-
// the npx runner, and whether the user links a bot below. Suppress init's
|
|
88
|
-
// own tail so there aren't two contradictory "Next steps" blocks.
|
|
89
|
-
env: { ...process.env, TGCLOUD_INIT_QUIET_NEXT: '1' },
|
|
90
93
|
});
|
|
91
94
|
} catch {
|
|
92
95
|
fail('\nScaffolding failed. Fix the error above and run "npx tgcloud init" in the project.');
|
|
@@ -106,11 +109,10 @@ async function main() {
|
|
|
106
109
|
}
|
|
107
110
|
}
|
|
108
111
|
|
|
109
|
-
// 5. The single "Next steps" for the whole bootstrap
|
|
110
|
-
//
|
|
111
|
-
//
|
|
112
|
-
//
|
|
113
|
-
// just linked. Plain text: create-bot has no chalk.
|
|
112
|
+
// 5. The single "Next steps" for the whole bootstrap. create-bot prints this,
|
|
113
|
+
// not the delegated CLI: it alone knows the `cd` target — a child process
|
|
114
|
+
// can't change the parent shell's cwd — the npx runner, and whether the user
|
|
115
|
+
// just linked a bot above. Plain text: create-bot has no chalk.
|
|
114
116
|
console.log('\nNext steps:');
|
|
115
117
|
if (target !== '.') console.log(` cd ${target}`);
|
|
116
118
|
if (!loggedIn) console.log(` ${'npx tgcloud login'.padEnd(17)} # link your bot`);
|