@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.
Files changed (2) hide show
  1. package/create.js +47 -24
  2. 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 { task } from '@ryziz/flow';
6
+ import { f } from '@ryziz/task';
7
7
 
8
- task('Initialize Project', {
9
- 'Locating': (c) => {
10
- const root = resolve(dirname(fileURLToPath(import.meta.url)), '../'), name = basename(process.argv[1]);
11
- c.src = [resolve(root, name), resolve(root, '../templates', name)].find((p) => exists(join(p, 'package.json')));
12
- if (!c.src) throw Error(`Template ${name} not found`);
13
- },
14
- 'Verifying': (c) => {
15
- if (!process.argv[2]) throw Error('Project name/directory is missing');
16
- if (exists(c.dest = resolve(process.argv[2]))) throw Error('Directory exists');
17
- },
18
- 'Cloning': ({ src, dest }) => {
19
- cpSync(src, dest, { recursive: true });
20
- if (exists(join(dest, 'gitignore'))) renameSync(join(dest, 'gitignore'), join(dest, '.gitignore'));
21
- },
22
- 'Configuring': ({ dest }) => {
23
- const p = join(dest, 'package.json'), pkg = JSON.parse(readFileSync(p));
24
- delete pkg.bin; pkg.name = basename(dest);
25
- if (pkg.dependencies?.['@ryziz/cli']) (pkg.devDependencies ||= {})['@ryziz/cli'] = pkg.dependencies['@ryziz/cli'], delete pkg.dependencies['@ryziz/cli'];
26
- writeFileSync(p, JSON.stringify(pkg, null, 2));
27
- },
28
- 'Installing': ({ dest }) => execSync('npm install', { cwd: dest }),
29
- 'Ready': ({ dest }) => console.log(dest),
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.52",
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/flow": "^0.0.24",
10
+ "@ryziz/task": "^0.0.3",
11
11
  "commander": "^14.0.2",
12
12
  "esbuild": "^0.27.2"
13
13
  }