create-routify 1.0.0-0 → 1.0.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.
Files changed (3) hide show
  1. package/package.json +2 -2
  2. package/src/bin.js +5 -2
  3. package/src/index.js +31 -30
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-routify",
3
- "version": "1.0.0-0",
3
+ "version": "1.0.0",
4
4
  "description": "A powerful cli for simplifying your routify development experience",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -26,9 +26,9 @@
26
26
  "url": "https://github.com/roxiness/create-routify/issues"
27
27
  },
28
28
  "dependencies": {
29
- "dashargs": "^4.1.5",
30
29
  "kleur": "^4.1.4",
31
30
  "log-symbols": "^5.1.0",
31
+ "minimist": "^1.2.5",
32
32
  "prompts": "^2.4.2",
33
33
  "update-notifier": "^5.0.1"
34
34
  },
package/src/bin.js CHANGED
@@ -2,9 +2,12 @@
2
2
  import updateNotifier from 'update-notifier';
3
3
  import { readFile } from 'fs/promises';
4
4
  import { run } from '../src/index.js';
5
- import { argv } from 'dashargs';
5
+ // import { argv } from 'dashargs';
6
+ import minimist from 'minimist';
6
7
 
7
- run(argv());
8
+ const args = minimist(process.argv.slice(2));
9
+
10
+ run({ args });
8
11
 
9
12
  try {
10
13
  const pkg = await readFile('../package.json', 'utf-8');
package/src/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { onCancel } from './utils/prompts.js';
2
+ import { existsSync, readdirSync } from 'fs';
2
3
  import { mkdir } from 'fs/promises';
3
4
  import symbols from 'log-symbols';
4
5
  import { relative } from 'path';
@@ -11,44 +12,44 @@ const versions = {
11
12
  3: () => import('./versions/three/index.js'),
12
13
  };
13
14
 
14
- /** @param {import('dashargs').DashArgs} args */
15
- export const run = async (args) => {
16
- console.clear(); // ! REMOVE ME
17
-
15
+ export const run = async ({ args }) => {
18
16
  console.log(` ${k.dim(`v${'1.0.0'}`)}`);
19
17
  console.log(` ${k.bold().magenta('Routify')} ${k.magenta().dim('CLI')}`);
20
18
  console.log();
21
19
 
22
- const { version, projectName } = await prompts(
23
- [
24
- // TODO disable this if version cli opt
25
- {
26
- type: 'select',
27
- name: 'version',
28
- message: 'Routify Version:',
29
- choices: [
30
- { title: 'Routify 2', value: 2 },
31
- {
32
- title: `Routify 3 ${k.bold().magenta('[BETA]')}`,
33
- value: 3,
34
- },
35
- ],
36
- },
37
- // TODO disable this if file name given
38
- {
39
- type: 'text',
40
- name: 'projectName',
41
- message: 'Project Name: ',
42
- initial: 'my-routify-app',
43
- },
44
- ],
20
+ const { version } = await prompts(
21
+ // TODO disable this if version cli opt
22
+ {
23
+ type: 'select',
24
+ name: 'version',
25
+ message: 'Routify Version:',
26
+ choices: [
27
+ { title: 'Routify 2', value: 2 },
28
+ {
29
+ title: `Routify 3 ${k.bold().magenta('[BETA]')}`,
30
+ value: 3,
31
+ },
32
+ ],
33
+ },
34
+
45
35
  { onCancel },
46
36
  );
47
37
 
48
- const projectDir = resolve(projectName);
38
+ const projectDir = resolve(args._[0] || '.');
39
+
40
+ if (existsSync(projectDir) && readdirSync(projectDir).length > 0) {
41
+ const { proceed } = await prompts(
42
+ {
43
+ type: 'confirm',
44
+ message: `Directory is not empty, continue?`,
45
+ name: 'proceed',
46
+ },
47
+ { onCancel },
48
+ );
49
+
50
+ if (!proceed) return onCancel();
51
+ }
49
52
 
50
- // TODO if dir exists and isn't empty check if it's ok to continue
51
- // TODO make passing dir npm init routify <dir>
52
53
  await mkdir(projectDir, { recursive: true });
53
54
 
54
55
  await runVersion(version, { args, projectDir });