vyriy 0.5.2 → 0.5.4
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/README.md +54 -36
- package/args.js +16 -0
- package/bin/vyriy.js +1 -1
- package/cli.js +68 -0
- package/package.json +52 -7
- package/types.d.ts +11 -0
- package/cli/args.js +0 -29
- package/cli/cli.js +0 -28
- package/cli/types.d.ts +0 -13
- package/commands/check-env.d.ts +0 -2
- package/commands/check-env.js +0 -120
- package/commands/create/index.d.ts +0 -2
- package/commands/create/index.js +0 -130
- package/commands/create/plan/index.d.ts +0 -4
- package/commands/create/plan/index.js +0 -3
- package/commands/create/plan/plan.d.ts +0 -7
- package/commands/create/plan/plan.js +0 -35
- package/commands/create/plan/question.d.ts +0 -2
- package/commands/create/plan/question.js +0 -25
- package/commands/create/plan/types.d.ts +0 -12
- package/commands/create/preset/api.d.ts +0 -2
- package/commands/create/preset/api.js +0 -63
- package/commands/create/preset/base.d.ts +0 -2
- package/commands/create/preset/base.js +0 -159
- package/commands/create/preset/fullstack.d.ts +0 -2
- package/commands/create/preset/fullstack.js +0 -158
- package/commands/create/preset/gql.d.ts +0 -2
- package/commands/create/preset/gql.js +0 -744
- package/commands/create/preset/index.d.ts +0 -52
- package/commands/create/preset/index.js +0 -62
- package/commands/create/preset/library.d.ts +0 -2
- package/commands/create/preset/library.js +0 -247
- package/commands/create/preset/mfe.d.ts +0 -2
- package/commands/create/preset/mfe.js +0 -326
- package/commands/create/preset/rest.d.ts +0 -2
- package/commands/create/preset/rest.js +0 -242
- package/commands/create/preset/shared.d.ts +0 -116
- package/commands/create/preset/shared.js +0 -245
- package/commands/create/preset/spa.d.ts +0 -2
- package/commands/create/preset/spa.js +0 -132
- package/commands/create/preset/ssg.d.ts +0 -2
- package/commands/create/preset/ssg.js +0 -171
- package/commands/create/preset/ssr.d.ts +0 -2
- package/commands/create/preset/ssr.js +0 -179
- package/commands/create/preset/types.d.ts +0 -9
- package/commands/create/prompt/conflict-strategy.d.ts +0 -5
- package/commands/create/prompt/conflict-strategy.js +0 -22
- package/commands/create/prompt/index.d.ts +0 -6
- package/commands/create/prompt/index.js +0 -5
- package/commands/create/prompt/preset.d.ts +0 -4
- package/commands/create/prompt/preset.js +0 -11
- package/commands/create/prompt/prompt.d.ts +0 -2
- package/commands/create/prompt/prompt.js +0 -4
- package/commands/create/prompt/resolve-option.d.ts +0 -6
- package/commands/create/prompt/resolve-option.js +0 -8
- package/commands/create/prompt/scope.d.ts +0 -2
- package/commands/create/prompt/scope.js +0 -2
- package/commands/create/prompt/types.d.ts +0 -4
- package/commands/dist.d.ts +0 -2
- package/commands/dist.js +0 -287
- package/commands/help.d.ts +0 -3
- package/commands/help.js +0 -24
- package/commands/index.d.ts +0 -5
- package/commands/index.js +0 -5
- package/commands/types.d.ts +0 -44
- package/commands/version.d.ts +0 -2
- package/commands/version.js +0 -6
- /package/{cli/args.d.ts → args.d.ts} +0 -0
- /package/{cli/cli.d.ts → cli.d.ts} +0 -0
- /package/{cli/index.d.ts → index.d.ts} +0 -0
- /package/{cli/index.js → index.js} +0 -0
package/README.md
CHANGED
|
@@ -25,22 +25,18 @@ yarn global add vyriy
|
|
|
25
25
|
## Usage
|
|
26
26
|
|
|
27
27
|
```bash
|
|
28
|
-
vyriy [name]
|
|
29
|
-
vyriy .
|
|
28
|
+
vyriy create [name] Create a new Vyriy project
|
|
29
|
+
vyriy create . Initialise a new Vyriy project in the current directory
|
|
30
|
+
vyriy dist Prepare dist package metadata without publishing to npm
|
|
31
|
+
vyriy static [dir] Serve a static directory (defaults to .)
|
|
32
|
+
vyriy check Check local environment (Node.js and Yarn versions)
|
|
30
33
|
vyriy --help, -h Show help
|
|
31
34
|
vyriy --version, -v Show version
|
|
32
|
-
vyriy --check-env, -c Check local environment (Node.js and Yarn versions)
|
|
33
|
-
vyriy --dist, -d Prepare dist package metadata without publishing to npm
|
|
34
|
-
vyriy --dry-run Print the merged file plan without writing project files
|
|
35
|
-
vyriy --overwrite Overwrite existing generated paths
|
|
36
|
-
vyriy --skip-existing Leave existing generated paths untouched
|
|
37
|
-
vyriy --no-install Create files without installing dependencies
|
|
38
|
-
vyriy --no-verify Install dependencies without running checks
|
|
39
35
|
```
|
|
40
36
|
|
|
41
37
|
## Commands
|
|
42
38
|
|
|
43
|
-
### `create`
|
|
39
|
+
### `create`
|
|
44
40
|
|
|
45
41
|
The interactive wizard collects project details and writes the scaffold:
|
|
46
42
|
|
|
@@ -60,12 +56,28 @@ When generated paths already exist, use `--overwrite` or `--skip-existing` to
|
|
|
60
56
|
avoid the interactive conflict prompt. Without either flag, `vyriy` asks whether
|
|
61
57
|
to overwrite existing files, skip them, or abort.
|
|
62
58
|
|
|
63
|
-
|
|
59
|
+
Create options:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
vyriy create --dry-run Print the merged file plan without writing project files
|
|
63
|
+
vyriy create --overwrite Overwrite existing generated paths
|
|
64
|
+
vyriy create --skip-existing Leave existing generated paths untouched
|
|
65
|
+
vyriy create --no-install Create files without installing dependencies
|
|
66
|
+
vyriy create --no-verify Install dependencies without running checks
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### `check`
|
|
64
70
|
|
|
65
71
|
Validates Node.js and Yarn versions against the engine requirements declared in
|
|
66
72
|
`package.json`.
|
|
67
73
|
|
|
68
|
-
|
|
74
|
+
```bash
|
|
75
|
+
vyriy check
|
|
76
|
+
vyriy check --help
|
|
77
|
+
vyriy check --version
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### `dist`
|
|
69
81
|
|
|
70
82
|
Prepares every package inside the `dist/` directory for npm publishing:
|
|
71
83
|
|
|
@@ -74,39 +86,45 @@ Prepares every package inside the `dist/` directory for npm publishing:
|
|
|
74
86
|
- Copies README, LICENSE, and AGENTS.md
|
|
75
87
|
- Makes bin files executable
|
|
76
88
|
|
|
89
|
+
```bash
|
|
90
|
+
vyriy dist
|
|
91
|
+
vyriy dist --help
|
|
92
|
+
vyriy dist --version
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### `static`
|
|
96
|
+
|
|
97
|
+
Starts the reusable `@vyriy/static` server command:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
vyriy static
|
|
101
|
+
vyriy static public
|
|
102
|
+
vyriy static --port 3000 dist
|
|
103
|
+
vyriy static --help
|
|
104
|
+
vyriy static --version
|
|
105
|
+
```
|
|
106
|
+
|
|
77
107
|
## Presets
|
|
78
108
|
|
|
79
109
|
Registered presets:
|
|
80
110
|
|
|
81
|
-
| Key
|
|
82
|
-
|
|
|
83
|
-
| `base`
|
|
84
|
-
| `library`
|
|
85
|
-
| `api`
|
|
86
|
-
| `ssr`
|
|
87
|
-
| `ssg`
|
|
88
|
-
| `spa`
|
|
89
|
-
| `rest`
|
|
90
|
-
| `gql`
|
|
91
|
-
| `mfe`
|
|
111
|
+
| Key | Description |
|
|
112
|
+
| ----------- | ------------------------------------------------- |
|
|
113
|
+
| `base` | Preset to create minimal monorepo with configs |
|
|
114
|
+
| `library` | Preset to create js/react library |
|
|
115
|
+
| `api` | Preset to create simple API |
|
|
116
|
+
| `ssr` | Preset to create Server Side Rendering (SSR) API |
|
|
117
|
+
| `ssg` | Preset to create Static site generation (SSG) |
|
|
118
|
+
| `spa` | Preset to create Single-page application (SPA) |
|
|
119
|
+
| `rest` | Preset to create simple REST API |
|
|
120
|
+
| `gql` | Preset to create GraphQL API |
|
|
121
|
+
| `mfe` | Preset to create Micro-frontend (MFE) application |
|
|
122
|
+
| `fullstack` | Preset to create Fullstack React app with SSR |
|
|
92
123
|
|
|
93
124
|
Registered presets are selectable by the wizard. In-progress presets exist as
|
|
94
125
|
source modules and are expected to become selectable as their generated project
|
|
95
126
|
shape is finalized.
|
|
96
127
|
|
|
97
|
-
## Providers
|
|
98
|
-
|
|
99
|
-
Provider selections add files to the generated project.
|
|
100
|
-
|
|
101
|
-
| Preset | CI/CD providers | Deploy providers |
|
|
102
|
-
| --------- | ------------------ | ---------------- |
|
|
103
|
-
| `base` | `gitlab`, `github` | none |
|
|
104
|
-
| `library` | `gitlab`, `github` | none |
|
|
105
|
-
| `api` | `gitlab`, `github` | none |
|
|
106
|
-
| `ssr` | `gitlab`, `github` | none |
|
|
107
|
-
| `ssg` | `gitlab`, `github` | none |
|
|
108
|
-
| `spa` | `gitlab`, `github` | none |
|
|
109
|
-
|
|
110
128
|
## API
|
|
111
129
|
|
|
112
130
|
```ts
|
package/args.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const parseArgs = (args) => {
|
|
2
|
+
const [command = '', ...commandArgs] = args;
|
|
3
|
+
if (command === 'check' || command === 'create' || command === 'dist' || command === 'static') {
|
|
4
|
+
return { type: command, args: commandArgs };
|
|
5
|
+
}
|
|
6
|
+
if (args.includes('--help') || args.includes('-h')) {
|
|
7
|
+
return { type: 'help' };
|
|
8
|
+
}
|
|
9
|
+
if (args.includes('--version') || args.includes('-v')) {
|
|
10
|
+
return { type: 'version' };
|
|
11
|
+
}
|
|
12
|
+
if (!command) {
|
|
13
|
+
return { type: 'help' };
|
|
14
|
+
}
|
|
15
|
+
return { type: 'unknown', command };
|
|
16
|
+
};
|
package/bin/vyriy.js
CHANGED
package/cli.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { parseArgs } from './args.js';
|
|
2
|
+
import packageJson from './package.json' with { type: 'json' };
|
|
3
|
+
const text = `Vyriy Project Master
|
|
4
|
+
|
|
5
|
+
Usage:
|
|
6
|
+
vyriy create [name] Create a new Vyriy project
|
|
7
|
+
vyriy create . Initialize a new Vyriy project in the current directory
|
|
8
|
+
vyriy dist Prepare dist package metadata without publishing to npm
|
|
9
|
+
vyriy static [dir] Serve a static directory (defaults to .)
|
|
10
|
+
vyriy check Check local environment
|
|
11
|
+
vyriy --help, -h Show help
|
|
12
|
+
vyriy --version, -v Show version
|
|
13
|
+
|
|
14
|
+
Create options:
|
|
15
|
+
vyriy create --dry-run Print the merged file plan without writing project files
|
|
16
|
+
vyriy create --overwrite Overwrite existing generated paths
|
|
17
|
+
vyriy create --skip-existing Leave existing generated paths untouched
|
|
18
|
+
vyriy create --no-install Create files without installing dependencies
|
|
19
|
+
vyriy create --no-verify Install dependencies without running checks
|
|
20
|
+
|
|
21
|
+
Examples:
|
|
22
|
+
vyriy create app
|
|
23
|
+
vyriy create app --dry-run
|
|
24
|
+
vyriy create .
|
|
25
|
+
vyriy create . --no-verify
|
|
26
|
+
vyriy dist
|
|
27
|
+
vyriy static
|
|
28
|
+
vyriy static --port 3000 dist
|
|
29
|
+
vyriy static dist
|
|
30
|
+
vyriy check`;
|
|
31
|
+
export const cli = async (args = []) => {
|
|
32
|
+
const command = parseArgs(args);
|
|
33
|
+
switch (command.type) {
|
|
34
|
+
case 'help':
|
|
35
|
+
console.log(text);
|
|
36
|
+
process.exitCode = 0;
|
|
37
|
+
break;
|
|
38
|
+
case 'version':
|
|
39
|
+
console.log(packageJson.version);
|
|
40
|
+
process.exitCode = 0;
|
|
41
|
+
break;
|
|
42
|
+
case 'dist': {
|
|
43
|
+
const { runDistCli } = await import('@vyriy/dist');
|
|
44
|
+
await runDistCli(command.args, 'vyriy dist', false);
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
case 'check': {
|
|
48
|
+
const { runCheckCli } = await import('@vyriy/check');
|
|
49
|
+
await runCheckCli(command.args, 'vyriy check', false);
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
case 'static': {
|
|
53
|
+
const { runStaticCli } = await import('@vyriy/static');
|
|
54
|
+
await runStaticCli(command.args, 'vyriy static', false);
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
case 'create': {
|
|
58
|
+
const { runCreateCli } = await import('@vyriy/create');
|
|
59
|
+
await runCreateCli(command.args, 'vyriy create', false);
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
default:
|
|
63
|
+
console.error(`Unknown command: ${command.command}\n`);
|
|
64
|
+
console.log(text);
|
|
65
|
+
process.exitCode = 1;
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
};
|
package/package.json
CHANGED
|
@@ -1,32 +1,38 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vyriy",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.4",
|
|
4
4
|
"description": "Interactive project master for calm cloud-ready applications.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": "./bin/vyriy.js",
|
|
7
7
|
"engines": {
|
|
8
8
|
"node": ">=24.0.0"
|
|
9
9
|
},
|
|
10
|
-
"packageManager": "yarn@4.
|
|
10
|
+
"packageManager": "yarn@4.16.0",
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@vyriy/check": "0.5.4",
|
|
13
|
+
"@vyriy/create": "0.5.4",
|
|
14
|
+
"@vyriy/dist": "0.5.4",
|
|
15
|
+
"@vyriy/static": "0.5.4"
|
|
16
|
+
},
|
|
11
17
|
"peerDependencies": {
|
|
12
18
|
"@testing-library/dom": "^10.4.1",
|
|
13
19
|
"@testing-library/react": "^16.3.2",
|
|
14
20
|
"@types/jest": "^30.0.0",
|
|
15
|
-
"@types/react": "^19.2.
|
|
21
|
+
"@types/react": "^19.2.16",
|
|
16
22
|
"@types/react-dom": "^19.2.3",
|
|
17
23
|
"cross-env": "^10.1.0",
|
|
18
24
|
"eslint": "^10.4.1",
|
|
19
|
-
"graphql": "^16.14.
|
|
25
|
+
"graphql": "^16.14.1",
|
|
20
26
|
"husky": "^9.1.7",
|
|
21
27
|
"jest": "^30.4.2",
|
|
22
28
|
"npm-run-all2": "^9.0.1",
|
|
23
29
|
"prettier": "^3.8.3",
|
|
24
|
-
"react": "^19.2.
|
|
25
|
-
"react-dom": "^19.2.
|
|
30
|
+
"react": "^19.2.7",
|
|
31
|
+
"react-dom": "^19.2.7",
|
|
26
32
|
"rimraf": "^6.1.3",
|
|
27
33
|
"sass": "^1.100.0",
|
|
28
34
|
"serve": "^14.2.6",
|
|
29
|
-
"storybook": "^10.4.
|
|
35
|
+
"storybook": "^10.4.2",
|
|
30
36
|
"stylelint": "^17.12.0",
|
|
31
37
|
"tsx": "^4.22.4",
|
|
32
38
|
"typescript": "^6.0.3",
|
|
@@ -110,5 +116,44 @@
|
|
|
110
116
|
"type": "git",
|
|
111
117
|
"url": "https://github.com/evheniy/vyriy",
|
|
112
118
|
"directory": "packages/vyriy"
|
|
119
|
+
},
|
|
120
|
+
"main": "./index.js",
|
|
121
|
+
"types": "./index.d.ts",
|
|
122
|
+
"exports": {
|
|
123
|
+
".": {
|
|
124
|
+
"types": "./index.d.ts",
|
|
125
|
+
"import": "./index.js",
|
|
126
|
+
"default": "./index.js"
|
|
127
|
+
},
|
|
128
|
+
"./args": {
|
|
129
|
+
"types": "./args.d.ts",
|
|
130
|
+
"import": "./args.js",
|
|
131
|
+
"default": "./args.js"
|
|
132
|
+
},
|
|
133
|
+
"./args.js": {
|
|
134
|
+
"types": "./args.d.ts",
|
|
135
|
+
"import": "./args.js",
|
|
136
|
+
"default": "./args.js"
|
|
137
|
+
},
|
|
138
|
+
"./cli": {
|
|
139
|
+
"types": "./cli.d.ts",
|
|
140
|
+
"import": "./cli.js",
|
|
141
|
+
"default": "./cli.js"
|
|
142
|
+
},
|
|
143
|
+
"./cli.js": {
|
|
144
|
+
"types": "./cli.d.ts",
|
|
145
|
+
"import": "./cli.js",
|
|
146
|
+
"default": "./cli.js"
|
|
147
|
+
},
|
|
148
|
+
"./index": {
|
|
149
|
+
"types": "./index.d.ts",
|
|
150
|
+
"import": "./index.js",
|
|
151
|
+
"default": "./index.js"
|
|
152
|
+
},
|
|
153
|
+
"./index.js": {
|
|
154
|
+
"types": "./index.d.ts",
|
|
155
|
+
"import": "./index.js",
|
|
156
|
+
"default": "./index.js"
|
|
157
|
+
}
|
|
113
158
|
}
|
|
114
159
|
}
|
package/types.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type Command = {
|
|
2
|
+
readonly type: 'help' | 'version';
|
|
3
|
+
} | {
|
|
4
|
+
readonly type: 'check' | 'create' | 'dist' | 'static';
|
|
5
|
+
readonly args: readonly string[];
|
|
6
|
+
} | {
|
|
7
|
+
readonly type: 'unknown';
|
|
8
|
+
readonly command: string;
|
|
9
|
+
};
|
|
10
|
+
export type ParseArgs = (args: readonly string[]) => Command;
|
|
11
|
+
export type Cli = (args?: readonly string[]) => Promise<void>;
|
package/cli/args.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
export const parseArgs = (args) => {
|
|
2
|
-
if (args.includes('--help') || args.includes('-h')) {
|
|
3
|
-
return { type: 'help' };
|
|
4
|
-
}
|
|
5
|
-
if (args.includes('--version') || args.includes('-v')) {
|
|
6
|
-
return { type: 'version' };
|
|
7
|
-
}
|
|
8
|
-
if (args.includes('--dist') || args.includes('-d')) {
|
|
9
|
-
return { type: 'dist' };
|
|
10
|
-
}
|
|
11
|
-
if (args.includes('--check-env') || args.includes('-c')) {
|
|
12
|
-
return { type: 'check-env' };
|
|
13
|
-
}
|
|
14
|
-
const dryRun = args.includes('--dry-run');
|
|
15
|
-
const overwrite = args.includes('--overwrite');
|
|
16
|
-
const skipExisting = args.includes('--skip-existing');
|
|
17
|
-
const install = !args.includes('--no-install');
|
|
18
|
-
const verify = install && !args.includes('--no-verify');
|
|
19
|
-
const directory = args.find((arg) => !arg.startsWith('-')) ?? '';
|
|
20
|
-
return {
|
|
21
|
-
type: 'create',
|
|
22
|
-
directory,
|
|
23
|
-
dryRun,
|
|
24
|
-
overwrite,
|
|
25
|
-
skipExisting,
|
|
26
|
-
install,
|
|
27
|
-
verify,
|
|
28
|
-
};
|
|
29
|
-
};
|
package/cli/cli.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { parseArgs } from './args.js';
|
|
2
|
-
import { help, version, dist, checkEnv, create } from '../commands/index.js';
|
|
3
|
-
export const cli = async (args = []) => {
|
|
4
|
-
const command = parseArgs(args);
|
|
5
|
-
switch (command.type) {
|
|
6
|
-
case 'help':
|
|
7
|
-
process.exitCode = await help();
|
|
8
|
-
break;
|
|
9
|
-
case 'version':
|
|
10
|
-
process.exitCode = await version();
|
|
11
|
-
break;
|
|
12
|
-
case 'dist':
|
|
13
|
-
process.exitCode = await dist();
|
|
14
|
-
break;
|
|
15
|
-
case 'check-env': {
|
|
16
|
-
process.exitCode = await checkEnv();
|
|
17
|
-
break;
|
|
18
|
-
}
|
|
19
|
-
case 'create':
|
|
20
|
-
process.exitCode = await create(command);
|
|
21
|
-
break;
|
|
22
|
-
default:
|
|
23
|
-
console.error(`Unknown command.\n`);
|
|
24
|
-
await help();
|
|
25
|
-
process.exitCode = 1;
|
|
26
|
-
break;
|
|
27
|
-
}
|
|
28
|
-
};
|
package/cli/types.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export type Command = {
|
|
2
|
-
readonly type: 'help' | 'version' | 'dist' | 'check-env';
|
|
3
|
-
} | {
|
|
4
|
-
readonly type: 'create';
|
|
5
|
-
readonly directory: string;
|
|
6
|
-
readonly dryRun: boolean;
|
|
7
|
-
readonly overwrite: boolean;
|
|
8
|
-
readonly skipExisting: boolean;
|
|
9
|
-
readonly install: boolean;
|
|
10
|
-
readonly verify: boolean;
|
|
11
|
-
};
|
|
12
|
-
export type ParseArgs = (args: readonly string[]) => Command;
|
|
13
|
-
export type Cli = (args?: readonly string[]) => Promise<void>;
|
package/commands/check-env.d.ts
DELETED
package/commands/check-env.js
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import { exec as processExec } from 'node:child_process';
|
|
2
|
-
import { promisify } from 'node:util';
|
|
3
|
-
import packageJson from '../package.json' with { type: 'json' };
|
|
4
|
-
const exec = promisify(processExec);
|
|
5
|
-
const yarnStableHint = 'Try:\n corepack enable\n corepack prepare yarn@stable --activate';
|
|
6
|
-
const node = () => {
|
|
7
|
-
const majorVersion = Number.parseInt(process.versions.node.split('.')[0]);
|
|
8
|
-
const minimumMajorVersion = Number.parseInt(packageJson.engines.node.match(/(\d+)/)?.[0]);
|
|
9
|
-
if (majorVersion && majorVersion >= minimumMajorVersion) {
|
|
10
|
-
return {
|
|
11
|
-
ok: true,
|
|
12
|
-
version: process.versions.node,
|
|
13
|
-
message: `Node.js ${majorVersion}`,
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
return {
|
|
17
|
-
ok: false,
|
|
18
|
-
version: process.versions.node,
|
|
19
|
-
message: `Vyriy requires Node.js >= ${minimumMajorVersion}.\n\nCurrent version: ${process.versions.node}\n\nPlease upgrade Node.js and run the command again.`,
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
const corepack = async () => {
|
|
23
|
-
let currentVersion;
|
|
24
|
-
try {
|
|
25
|
-
const { stdout } = await exec('corepack --version');
|
|
26
|
-
currentVersion = stdout.trim();
|
|
27
|
-
}
|
|
28
|
-
catch {
|
|
29
|
-
return {
|
|
30
|
-
ok: false,
|
|
31
|
-
message: `Corepack was not found.\n\nVyriy uses Corepack to install Yarn stable.\n\nInstall a Node.js distribution that includes Corepack and run the command again.`,
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
return {
|
|
35
|
-
ok: true,
|
|
36
|
-
message: `Corepack ${currentVersion}`,
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
const activateYarnStable = async () => {
|
|
40
|
-
try {
|
|
41
|
-
await exec('corepack enable');
|
|
42
|
-
await exec('corepack prepare yarn@stable --activate');
|
|
43
|
-
}
|
|
44
|
-
catch {
|
|
45
|
-
return {
|
|
46
|
-
ok: false,
|
|
47
|
-
message: `Corepack could not activate Yarn stable.\n\n${yarnStableHint}`,
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
return {
|
|
51
|
-
ok: true,
|
|
52
|
-
message: 'Yarn stable activated',
|
|
53
|
-
};
|
|
54
|
-
};
|
|
55
|
-
const yarn = async () => {
|
|
56
|
-
const minimumMajorVersion = Number.parseInt(packageJson.packageManager.match(/(\d+)/)?.[0]);
|
|
57
|
-
let currentVersion;
|
|
58
|
-
try {
|
|
59
|
-
const { stdout } = await exec('yarn --version');
|
|
60
|
-
currentVersion = stdout.trim();
|
|
61
|
-
}
|
|
62
|
-
catch {
|
|
63
|
-
return {
|
|
64
|
-
ok: false,
|
|
65
|
-
message: `Yarn was not found.\n\nVyriy requires Yarn >= ${minimumMajorVersion}.\n\n${yarnStableHint}`,
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
const majorVersion = Number.parseInt(currentVersion.match(/(\d+)/)?.[0]);
|
|
69
|
-
if (majorVersion && majorVersion >= minimumMajorVersion) {
|
|
70
|
-
return {
|
|
71
|
-
ok: true,
|
|
72
|
-
message: `Yarn ${currentVersion}`,
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
return {
|
|
76
|
-
ok: false,
|
|
77
|
-
message: `Vyriy requires Yarn >= ${minimumMajorVersion}.\n\nCurrent version: ${currentVersion}\n\n${yarnStableHint}`,
|
|
78
|
-
};
|
|
79
|
-
};
|
|
80
|
-
export const checkEnv = async () => {
|
|
81
|
-
const nodeResults = node();
|
|
82
|
-
console.log('Check env:');
|
|
83
|
-
if (nodeResults.ok) {
|
|
84
|
-
console.log(' ', nodeResults.message);
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
|
-
console.error(nodeResults.message);
|
|
88
|
-
return 1;
|
|
89
|
-
}
|
|
90
|
-
const corepackResults = await corepack();
|
|
91
|
-
if (corepackResults.ok) {
|
|
92
|
-
console.log(' ', corepackResults.message);
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
console.error(corepackResults.message);
|
|
96
|
-
return 1;
|
|
97
|
-
}
|
|
98
|
-
let yarnResults = await yarn();
|
|
99
|
-
if (yarnResults.ok) {
|
|
100
|
-
console.log(' ', yarnResults.message);
|
|
101
|
-
return 0;
|
|
102
|
-
}
|
|
103
|
-
const yarnStableResults = await activateYarnStable();
|
|
104
|
-
if (yarnStableResults.ok) {
|
|
105
|
-
console.log(' ', yarnStableResults.message);
|
|
106
|
-
}
|
|
107
|
-
else {
|
|
108
|
-
console.error(yarnStableResults.message);
|
|
109
|
-
return 1;
|
|
110
|
-
}
|
|
111
|
-
yarnResults = await yarn();
|
|
112
|
-
if (yarnResults.ok) {
|
|
113
|
-
console.log(' ', yarnResults.message);
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
console.error(yarnResults.message);
|
|
117
|
-
return 1;
|
|
118
|
-
}
|
|
119
|
-
return 0;
|
|
120
|
-
};
|
package/commands/create/index.js
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import { cwd } from 'node:process';
|
|
2
|
-
import { basename, dirname, resolve } from 'node:path';
|
|
3
|
-
import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
4
|
-
import { exec as processExec } from 'node:child_process';
|
|
5
|
-
import { promisify } from 'node:util';
|
|
6
|
-
import { checkEnv } from '../check-env.js';
|
|
7
|
-
import { plan } from './plan/index.js';
|
|
8
|
-
import { conflictStrategy as promptConflictStrategy } from './prompt/index.js';
|
|
9
|
-
import { presets } from './preset/index.js';
|
|
10
|
-
const exec = promisify(processExec);
|
|
11
|
-
const isPresetName = (preset) => preset in presets;
|
|
12
|
-
const mergeFiles = (planOption) => {
|
|
13
|
-
if (!isPresetName(planOption.preset)) {
|
|
14
|
-
return undefined;
|
|
15
|
-
}
|
|
16
|
-
const preset = presets[planOption.preset].preset;
|
|
17
|
-
return preset(planOption);
|
|
18
|
-
};
|
|
19
|
-
const getSortedFileNames = (files) => Object.keys(files).sort((a, b) => a.localeCompare(b));
|
|
20
|
-
const logFilePlan = (target, files) => {
|
|
21
|
-
console.log(`\nFile plan (${target}):`);
|
|
22
|
-
console.log(' ', getSortedFileNames(files).join('\n '));
|
|
23
|
-
};
|
|
24
|
-
const getExistingFiles = (target, files) => {
|
|
25
|
-
const existingFiles = getSortedFileNames(files).filter((file) => existsSync(resolve(target, file)));
|
|
26
|
-
if (existingFiles.length) {
|
|
27
|
-
console.log('\nExisting files found:\n');
|
|
28
|
-
existingFiles.forEach((file) => console.log(' ', file));
|
|
29
|
-
}
|
|
30
|
-
return existingFiles;
|
|
31
|
-
};
|
|
32
|
-
const resolveConflictStrategy = async (filesExist, overwrite, skipExisting) => {
|
|
33
|
-
if (!filesExist || overwrite || skipExisting) {
|
|
34
|
-
return { overwrite, skipExisting };
|
|
35
|
-
}
|
|
36
|
-
const strategy = await promptConflictStrategy();
|
|
37
|
-
if (strategy) {
|
|
38
|
-
return strategy;
|
|
39
|
-
}
|
|
40
|
-
console.error('\nCannot continue without a conflict strategy.\n');
|
|
41
|
-
console.error('Use one of:\n\n vyriy --overwrite\n vyriy --skip-existing\n vyriy --dry-run');
|
|
42
|
-
return undefined;
|
|
43
|
-
};
|
|
44
|
-
const writeFiles = (target, files, overwrite) => {
|
|
45
|
-
console.log(`\nFile creating (${target}):`);
|
|
46
|
-
getSortedFileNames(files).forEach((file) => {
|
|
47
|
-
if (!existsSync(resolve(target, file)) || overwrite) {
|
|
48
|
-
console.log(' ', file);
|
|
49
|
-
const filePath = resolve(target, file);
|
|
50
|
-
mkdirSync(dirname(filePath), { recursive: true });
|
|
51
|
-
writeFileSync(filePath, files[file]);
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
};
|
|
55
|
-
const verifyProject = async (target) => {
|
|
56
|
-
console.log('Running checks...');
|
|
57
|
-
try {
|
|
58
|
-
await exec(`yarn --cwd ${target} check`);
|
|
59
|
-
}
|
|
60
|
-
catch {
|
|
61
|
-
console.log('Running fixes...');
|
|
62
|
-
await exec(`yarn --cwd ${target} fix`);
|
|
63
|
-
console.log('Running checks...');
|
|
64
|
-
await exec(`yarn --cwd ${target} check`);
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
const installAndVerify = async (target, install, verify) => {
|
|
68
|
-
if (install) {
|
|
69
|
-
console.log('Installing dependencies...');
|
|
70
|
-
await exec(`yarn --cwd ${target} set version berry`);
|
|
71
|
-
await exec(`yarn --cwd ${target} install`);
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
console.log('Installing dependencies... SKIPPED');
|
|
75
|
-
console.log('Running checks... SKIPPED');
|
|
76
|
-
console.log('\nProject files were created.');
|
|
77
|
-
return 0;
|
|
78
|
-
}
|
|
79
|
-
if (verify) {
|
|
80
|
-
await verifyProject(target);
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
console.log('Running checks... SKIPPED');
|
|
84
|
-
console.log('\nProject files were created.');
|
|
85
|
-
return 0;
|
|
86
|
-
}
|
|
87
|
-
return 0;
|
|
88
|
-
};
|
|
89
|
-
export const create = async (options) => {
|
|
90
|
-
const { directory, dryRun, overwrite, skipExisting, install, verify } = options;
|
|
91
|
-
const checkEnvCode = await checkEnv();
|
|
92
|
-
if (checkEnvCode) {
|
|
93
|
-
return checkEnvCode;
|
|
94
|
-
}
|
|
95
|
-
const cliPath = cwd();
|
|
96
|
-
let dirName = 'app';
|
|
97
|
-
let appPath = resolve(cliPath, dirName);
|
|
98
|
-
if (directory) {
|
|
99
|
-
if (directory === '.') {
|
|
100
|
-
dirName = basename(cliPath);
|
|
101
|
-
appPath = cliPath;
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
dirName = directory;
|
|
105
|
-
appPath = resolve(cwd(), dirName);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
const planOption = await plan(dirName, appPath);
|
|
109
|
-
if (planOption) {
|
|
110
|
-
const { target } = planOption;
|
|
111
|
-
const files = mergeFiles(planOption);
|
|
112
|
-
if (!files) {
|
|
113
|
-
console.error(`Unknown preset: ${planOption.preset}`);
|
|
114
|
-
return 1;
|
|
115
|
-
}
|
|
116
|
-
if (dryRun) {
|
|
117
|
-
logFilePlan(target, files);
|
|
118
|
-
return 0;
|
|
119
|
-
}
|
|
120
|
-
console.log(`\nFile checking (${target})...`);
|
|
121
|
-
const existingFiles = getExistingFiles(target, files);
|
|
122
|
-
const conflictStrategy = await resolveConflictStrategy(Boolean(existingFiles.length), overwrite, skipExisting);
|
|
123
|
-
if (!conflictStrategy) {
|
|
124
|
-
return 1;
|
|
125
|
-
}
|
|
126
|
-
writeFiles(target, files, conflictStrategy.overwrite);
|
|
127
|
-
return installAndVerify(target, install, verify);
|
|
128
|
-
}
|
|
129
|
-
return 1;
|
|
130
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export declare const plan: (dirName: string, appPath: string) => Promise<{
|
|
2
|
-
name: string;
|
|
3
|
-
description: string;
|
|
4
|
-
target: string;
|
|
5
|
-
preset: "ssr" | "base" | "rest" | "api" | "library" | "gql" | "ssg" | "spa" | "mfe" | "fullstack";
|
|
6
|
-
scope: string | undefined;
|
|
7
|
-
} | undefined>;
|