create-synapse-mfe 1.0.12 → 1.1.0
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 +21 -0
- package/package.json +1 -1
package/bin/index.js
CHANGED
|
@@ -50,8 +50,23 @@ const getProjectName = () => {
|
|
|
50
50
|
});
|
|
51
51
|
};
|
|
52
52
|
|
|
53
|
+
const getScopeName = () => {
|
|
54
|
+
return new Promise((resolve) => {
|
|
55
|
+
if (process.argv[3]) {
|
|
56
|
+
resolve(process.argv[3]);
|
|
57
|
+
} else {
|
|
58
|
+
rl.question('\n\x1b[33m? Nama NPM scope organisasi Anda:\x1b[0m (@synapse) ', (answer) => {
|
|
59
|
+
let scope = answer.trim() || '@synapse';
|
|
60
|
+
if (!scope.startsWith('@')) scope = '@' + scope;
|
|
61
|
+
resolve(scope);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
|
|
53
67
|
(async () => {
|
|
54
68
|
const projectName = await getProjectName();
|
|
69
|
+
const scopeName = await getScopeName();
|
|
55
70
|
const currentDir = process.cwd();
|
|
56
71
|
const projectPath = path.join(currentDir, projectName);
|
|
57
72
|
|
|
@@ -91,6 +106,12 @@ const getProjectName = () => {
|
|
|
91
106
|
console.log(`\x1b[32mMemulai repositori Git baru...\x1b[0m`);
|
|
92
107
|
runCommand(`git init`, { cwd: projectPath });
|
|
93
108
|
|
|
109
|
+
if (scopeName !== '@synapse') {
|
|
110
|
+
console.log(`\n\x1b[32mMengganti NPM scope menjadi \x1b[1m${scopeName}\x1b[0m...\x1b[0m`);
|
|
111
|
+
// Memanggil script rebranding otomatis yang sudah ada dalam template
|
|
112
|
+
runCommand(`node scripts/setup-scope.js ${scopeName}`, { cwd: projectPath });
|
|
113
|
+
}
|
|
114
|
+
|
|
94
115
|
console.log(`\n\x1b[36mBerhasil! Proyek "\x1b[1m${projectName}\x1b[0m\x1b[36m" telah siap.\n`);
|
|
95
116
|
console.log('Langkah selanjutnya yang harus Anda lakukan:');
|
|
96
117
|
console.log(`\x1b[33m cd ${projectName}\x1b[0m`);
|