@ryziz/cli 0.0.52 → 0.0.54
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/create.js +47 -24
- package/package.json +2 -2
package/create.js
CHANGED
|
@@ -3,28 +3,51 @@ import { existsSync as exists, cpSync, renameSync, readFileSync, writeFileSync }
|
|
|
3
3
|
import { resolve, join, dirname, basename } from 'node:path';
|
|
4
4
|
import { fileURLToPath } from 'node:url';
|
|
5
5
|
import { execSync } from 'node:child_process';
|
|
6
|
-
import {
|
|
6
|
+
import { f } from '@ryziz/task';
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
'
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
8
|
+
const root = resolve(dirname(fileURLToPath(import.meta.url)), '../');
|
|
9
|
+
const name = basename(process.argv[1]);
|
|
10
|
+
const dest = process.argv[2] ? resolve(process.argv[2]) : null;
|
|
11
|
+
const src = [resolve(root, name), resolve(root, '../templates', name)]
|
|
12
|
+
.find((p) => exists(join(p, 'package.json')));
|
|
13
|
+
|
|
14
|
+
f('Initializing',
|
|
15
|
+
f('Verifying', verifying),
|
|
16
|
+
f('Cloning', cloning),
|
|
17
|
+
f('Configuring', configuring),
|
|
18
|
+
f('Installing', installing),
|
|
19
|
+
f('Completing', completing),
|
|
20
|
+
)();
|
|
21
|
+
|
|
22
|
+
function verifying() {
|
|
23
|
+
if (!src) throw Error(`Template ${name} not found`);
|
|
24
|
+
if (!dest) throw Error('Project name/directory is missing');
|
|
25
|
+
if (exists(dest)) throw Error('Directory exists');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function cloning() {
|
|
29
|
+
cpSync(src, dest, { recursive: true });
|
|
30
|
+
if (exists(join(dest, 'gitignore'))) {
|
|
31
|
+
renameSync(join(dest, 'gitignore'), join(dest, '.gitignore'));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function configuring() {
|
|
36
|
+
const pkgPath = join(dest, 'package.json');
|
|
37
|
+
const pkg = JSON.parse(readFileSync(pkgPath));
|
|
38
|
+
delete pkg.bin;
|
|
39
|
+
pkg.name = basename(dest);
|
|
40
|
+
if (pkg.dependencies?.['@ryziz/cli']) {
|
|
41
|
+
(pkg.devDependencies ||= {})['@ryziz/cli'] = pkg.dependencies['@ryziz/cli'];
|
|
42
|
+
delete pkg.dependencies['@ryziz/cli'];
|
|
43
|
+
}
|
|
44
|
+
writeFileSync(pkgPath, JSON.stringify(pkg, null, 2));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function installing() {
|
|
48
|
+
execSync('npm install', { cwd: dest });
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function completing() {
|
|
52
|
+
console.log(dest);
|
|
53
|
+
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ryziz/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.54",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"ryziz": "./index.js",
|
|
7
7
|
"create-react": "./create.js"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@ryziz/
|
|
10
|
+
"@ryziz/task": "^0.0.3",
|
|
11
11
|
"commander": "^14.0.2",
|
|
12
12
|
"esbuild": "^0.27.2"
|
|
13
13
|
}
|