vyriy 0.3.9 → 0.4.1
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 +75 -179
- package/bin/vyriy.js +2 -2
- package/cli/args.js +29 -0
- package/cli/cli.d.ts +2 -2
- package/cli/cli.js +18 -69
- package/cli/index.d.ts +1 -1
- package/cli/index.js +1 -1
- package/cli/types.d.ts +12 -3
- package/commands/check-env.d.ts +2 -0
- package/commands/check-env.js +65 -0
- package/commands/create/index.d.ts +2 -0
- package/commands/create/index.js +121 -0
- package/commands/create/plan/index.d.ts +4 -0
- package/commands/create/plan/index.js +3 -0
- package/commands/create/plan/plan.d.ts +9 -0
- package/commands/create/plan/plan.js +34 -0
- package/commands/create/plan/question.d.ts +2 -0
- package/commands/create/plan/question.js +25 -0
- package/commands/create/plan/types.d.ts +14 -0
- package/commands/create/preset/api.d.ts +2 -0
- package/commands/create/preset/api.js +168 -0
- package/commands/create/preset/base.d.ts +2 -0
- package/commands/create/preset/base.js +195 -0
- package/commands/create/preset/gql.d.ts +2 -0
- package/commands/create/preset/gql.js +16 -0
- package/commands/create/preset/index.d.ts +17 -0
- package/commands/create/preset/index.js +20 -0
- package/commands/create/preset/library.d.ts +2 -0
- package/commands/create/preset/library.js +252 -0
- package/commands/create/preset/mfe.d.ts +2 -0
- package/commands/create/preset/mfe.js +16 -0
- package/commands/create/preset/rest.d.ts +2 -0
- package/commands/create/preset/rest.js +16 -0
- package/commands/create/preset/spa.d.ts +2 -0
- package/commands/create/preset/spa.js +16 -0
- package/commands/create/preset/ssg.d.ts +2 -0
- package/commands/create/preset/ssg.js +16 -0
- package/commands/create/preset/ssr.d.ts +2 -0
- package/commands/create/preset/ssr.js +16 -0
- package/commands/create/preset/types.d.ts +15 -0
- package/commands/create/prompt/conflict-strategy.d.ts +5 -0
- package/commands/create/prompt/conflict-strategy.js +22 -0
- package/commands/create/prompt/index.d.ts +7 -0
- package/commands/create/prompt/index.js +6 -0
- package/commands/create/prompt/preset.d.ts +4 -0
- package/commands/create/prompt/preset.js +11 -0
- package/commands/create/prompt/prompt.d.ts +2 -0
- package/commands/create/prompt/prompt.js +4 -0
- package/commands/create/prompt/provider.d.ts +2 -0
- package/commands/create/prompt/provider.js +13 -0
- package/commands/create/prompt/resolve-option.d.ts +6 -0
- package/commands/create/prompt/resolve-option.js +8 -0
- package/commands/create/prompt/scope.d.ts +2 -0
- package/commands/create/prompt/scope.js +2 -0
- package/commands/create/prompt/types.d.ts +4 -0
- package/commands/dist.d.ts +2 -0
- package/commands/{publish/publish.js → dist.js} +22 -9
- package/commands/help.d.ts +3 -0
- package/commands/help.js +24 -0
- package/commands/index.d.ts +5 -0
- package/commands/index.js +5 -0
- package/commands/{publish/types.d.ts → types.d.ts} +18 -4
- package/commands/version.d.ts +2 -0
- package/commands/version.js +6 -0
- package/package.json +20 -588
- package/bin/vyriy.d.ts +0 -2
- package/checks/node/index.d.ts +0 -2
- package/checks/node/index.js +0 -1
- package/checks/node/node.d.ts +0 -2
- package/checks/node/node.js +0 -22
- package/checks/node/types.d.ts +0 -11
- package/checks/yarn/index.d.ts +0 -2
- package/checks/yarn/index.js +0 -1
- package/checks/yarn/types.d.ts +0 -7
- package/checks/yarn/yarn.d.ts +0 -2
- package/checks/yarn/yarn.js +0 -40
- package/cli/args/args.js +0 -40
- package/cli/args/index.d.ts +0 -2
- package/cli/args/index.js +0 -1
- package/cli/args/types.d.ts +0 -24
- package/commands/doctor/doctor.d.ts +0 -2
- package/commands/doctor/doctor.js +0 -9
- package/commands/doctor/index.d.ts +0 -2
- package/commands/doctor/index.js +0 -1
- package/commands/doctor/types.d.ts +0 -8
- package/commands/init/index.d.ts +0 -2
- package/commands/init/index.js +0 -1
- package/commands/init/init.d.ts +0 -2
- package/commands/init/init.js +0 -7
- package/commands/init/types.d.ts +0 -5
- package/commands/new/index.d.ts +0 -2
- package/commands/new/index.js +0 -1
- package/commands/new/new.d.ts +0 -3
- package/commands/new/new.js +0 -189
- package/commands/new/types.d.ts +0 -15
- package/commands/publish/index.d.ts +0 -2
- package/commands/publish/index.js +0 -1
- package/commands/publish/publish.d.ts +0 -2
- package/doctor/checkCorepack.d.ts +0 -2
- package/doctor/checkCorepack.js +0 -24
- package/doctor/checkGit.d.ts +0 -2
- package/doctor/checkGit.js +0 -23
- package/doctor/checkNodeVersion.d.ts +0 -5
- package/doctor/checkNodeVersion.js +0 -24
- package/doctor/checkYarn.d.ts +0 -10
- package/doctor/checkYarn.js +0 -45
- package/doctor/createDoctorReport.d.ts +0 -2
- package/doctor/createDoctorReport.js +0 -17
- package/doctor/index.d.ts +0 -7
- package/doctor/index.js +0 -6
- package/doctor/printDoctorReport.d.ts +0 -2
- package/doctor/printDoctorReport.js +0 -42
- package/doctor/types.d.ts +0 -25
- package/file-plan/createFilePlan.d.ts +0 -4
- package/file-plan/createFilePlan.js +0 -29
- package/file-plan/index.d.ts +0 -4
- package/file-plan/index.js +0 -3
- package/file-plan/printFilePlan.d.ts +0 -2
- package/file-plan/printFilePlan.js +0 -44
- package/file-plan/types.d.ts +0 -12
- package/file-plan/writeFilePlan.d.ts +0 -2
- package/file-plan/writeFilePlan.js +0 -12
- package/index.d.ts +0 -12
- package/index.js +0 -12
- package/presets/agentsTemplate.d.ts +0 -1
- package/presets/agentsTemplate.js +0 -105
- package/presets/base/createBaseFiles.d.ts +0 -3
- package/presets/base/createBaseFiles.js +0 -307
- package/presets/config.d.ts +0 -28
- package/presets/config.js +0 -7
- package/presets/createProjectFiles.d.ts +0 -2
- package/presets/createProjectFiles.js +0 -8
- package/presets/index.d.ts +0 -2
- package/presets/index.js +0 -1
- package/presets/library/createLibraryUiFiles.d.ts +0 -3
- package/presets/library/createLibraryUiFiles.js +0 -127
- package/presets/packages/createPackageFiles.d.ts +0 -3
- package/presets/packages/createPackageFiles.js +0 -39
- package/presets/packages/createPackageManifest.d.ts +0 -7
- package/presets/packages/createPackageManifest.js +0 -13
- package/presets/types.d.ts +0 -3
- package/presets/workspaces/createWorkspaceFiles.d.ts +0 -3
- package/presets/workspaces/createWorkspaceFiles.js +0 -98
- package/project-plan/api/api.d.ts +0 -6
- package/project-plan/api/api.js +0 -44
- package/project-plan/api/index.d.ts +0 -2
- package/project-plan/api/index.js +0 -1
- package/project-plan/api/types.d.ts +0 -11
- package/project-plan/ci/ci.d.ts +0 -3
- package/project-plan/ci/ci.js +0 -20
- package/project-plan/ci/index.d.ts +0 -2
- package/project-plan/ci/index.js +0 -1
- package/project-plan/ci/types.d.ts +0 -6
- package/project-plan/create/create.d.ts +0 -2
- package/project-plan/create/create.js +0 -129
- package/project-plan/create/index.d.ts +0 -2
- package/project-plan/create/index.js +0 -1
- package/project-plan/create/types.d.ts +0 -13
- package/project-plan/index.d.ts +0 -6
- package/project-plan/index.js +0 -5
- package/project-plan/kind/index.d.ts +0 -2
- package/project-plan/kind/index.js +0 -1
- package/project-plan/kind/kind.d.ts +0 -2
- package/project-plan/kind/kind.js +0 -1
- package/project-plan/kind/types.d.ts +0 -2
- package/project-plan/print/index.d.ts +0 -2
- package/project-plan/print/index.js +0 -1
- package/project-plan/print/print.d.ts +0 -2
- package/project-plan/print/print.js +0 -47
- package/project-plan/print/types.d.ts +0 -2
- package/project-plan/types.d.ts +0 -46
- package/prompts/project-plan/index.d.ts +0 -2
- package/prompts/project-plan/index.js +0 -1
- package/prompts/project-plan/project-plan.d.ts +0 -2
- package/prompts/project-plan/project-plan.js +0 -198
- package/prompts/project-plan/types.d.ts +0 -18
- package/shared/commandExists.d.ts +0 -2
- package/shared/commandExists.js +0 -10
- package/shared/execCommand.d.ts +0 -2
- package/shared/execCommand.js +0 -7
- package/shared/fileExists.d.ts +0 -2
- package/shared/fileExists.js +0 -10
- package/shared/index.d.ts +0 -6
- package/shared/index.js +0 -5
- package/shared/runCommand.d.ts +0 -9
- package/shared/runCommand.js +0 -34
- package/shared/semver.d.ts +0 -1
- package/shared/semver.js +0 -4
- package/shared/types.d.ts +0 -12
- /package/cli/{args/args.d.ts → args.d.ts} +0 -0
package/checks/node/node.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
const getMajorVersion = (version) => {
|
|
2
|
-
const majorVersion = /^v?(\d+)/.exec(version)?.[1];
|
|
3
|
-
return majorVersion ? Number.parseInt(majorVersion, 10) : undefined;
|
|
4
|
-
};
|
|
5
|
-
export const checkNodeVersion = ({ minimumMajor = 24, version = process.version } = {}) => {
|
|
6
|
-
const majorVersion = getMajorVersion(version);
|
|
7
|
-
const normalizedVersion = version.replace(/^v/, '');
|
|
8
|
-
if (majorVersion && majorVersion >= minimumMajor) {
|
|
9
|
-
return {
|
|
10
|
-
ok: true,
|
|
11
|
-
name: 'Node.js',
|
|
12
|
-
version: normalizedVersion,
|
|
13
|
-
message: `Node.js ${normalizedVersion}`,
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
return {
|
|
17
|
-
ok: false,
|
|
18
|
-
name: 'Node.js',
|
|
19
|
-
version: normalizedVersion,
|
|
20
|
-
message: `Vyriy requires Node.js >= ${minimumMajor}.\n\nCurrent version: ${normalizedVersion}\n\nPlease upgrade Node.js and run the command again.`,
|
|
21
|
-
};
|
|
22
|
-
};
|
package/checks/node/types.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export type EnvironmentCheckResult = {
|
|
2
|
-
readonly ok: boolean;
|
|
3
|
-
readonly name: string;
|
|
4
|
-
readonly version?: string;
|
|
5
|
-
readonly message: string;
|
|
6
|
-
};
|
|
7
|
-
export type CheckNodeVersionOptions = {
|
|
8
|
-
readonly version?: string;
|
|
9
|
-
readonly minimumMajor?: number;
|
|
10
|
-
};
|
|
11
|
-
export type CheckNodeVersion = (options?: CheckNodeVersionOptions) => EnvironmentCheckResult;
|
package/checks/yarn/index.d.ts
DELETED
package/checks/yarn/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './yarn.js';
|
package/checks/yarn/types.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { EnvironmentCheckResult } from '../node/index.js';
|
|
2
|
-
export type CheckYarnVersionOptions = {
|
|
3
|
-
readonly version?: string;
|
|
4
|
-
readonly minimumMajor?: number;
|
|
5
|
-
readonly run?: () => Promise<string>;
|
|
6
|
-
};
|
|
7
|
-
export type CheckYarnVersion = (options?: CheckYarnVersionOptions) => Promise<EnvironmentCheckResult>;
|
package/checks/yarn/yarn.d.ts
DELETED
package/checks/yarn/yarn.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { execFile } from 'node:child_process';
|
|
2
|
-
import { promisify } from 'node:util';
|
|
3
|
-
const execFileAsync = promisify(execFile);
|
|
4
|
-
const getMajorVersion = (version) => {
|
|
5
|
-
const majorVersion = /^(\d+)/.exec(version.trim())?.[1];
|
|
6
|
-
return majorVersion ? Number.parseInt(majorVersion, 10) : undefined;
|
|
7
|
-
};
|
|
8
|
-
const getYarnVersion = async () => {
|
|
9
|
-
const { stdout } = await execFileAsync('yarn', ['--version']);
|
|
10
|
-
return stdout.trim();
|
|
11
|
-
};
|
|
12
|
-
export const checkYarnVersion = async ({ minimumMajor = 4, run = getYarnVersion, version } = {}) => {
|
|
13
|
-
let currentVersion = version;
|
|
14
|
-
try {
|
|
15
|
-
currentVersion ??= await run();
|
|
16
|
-
}
|
|
17
|
-
catch {
|
|
18
|
-
return {
|
|
19
|
-
ok: false,
|
|
20
|
-
name: 'Yarn',
|
|
21
|
-
message: 'Yarn was not found.\n\nVyriy requires Yarn >= 4.\n\nTry:\n corepack enable\n yarn set version stable',
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
const normalizedVersion = currentVersion.trim();
|
|
25
|
-
const majorVersion = getMajorVersion(normalizedVersion);
|
|
26
|
-
if (majorVersion && majorVersion >= minimumMajor) {
|
|
27
|
-
return {
|
|
28
|
-
ok: true,
|
|
29
|
-
name: 'Yarn',
|
|
30
|
-
version: normalizedVersion,
|
|
31
|
-
message: `Yarn ${normalizedVersion}`,
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
return {
|
|
35
|
-
ok: false,
|
|
36
|
-
name: 'Yarn',
|
|
37
|
-
version: normalizedVersion,
|
|
38
|
-
message: `Vyriy requires Yarn >= ${minimumMajor}.\n\nCurrent version: ${normalizedVersion}\n\nTry:\n corepack enable\n yarn set version stable`,
|
|
39
|
-
};
|
|
40
|
-
};
|
package/cli/args/args.js
DELETED
|
@@ -1,40 +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
|
-
const dryRun = args.includes('--dry-run');
|
|
9
|
-
const install = !args.includes('--no-install');
|
|
10
|
-
const verify = install && (args.includes('--verify') || (!args.includes('--no-verify') && !args.includes('--install-only')));
|
|
11
|
-
const yes = args.includes('--yes') || args.includes('-y');
|
|
12
|
-
const overwrite = args.includes('--overwrite');
|
|
13
|
-
const skipExisting = args.includes('--skip-existing');
|
|
14
|
-
const positionalArgs = args.filter((arg) => !arg.startsWith('-'));
|
|
15
|
-
const [command, projectName] = positionalArgs;
|
|
16
|
-
const options = {
|
|
17
|
-
dryRun,
|
|
18
|
-
install,
|
|
19
|
-
yes,
|
|
20
|
-
overwrite,
|
|
21
|
-
verify,
|
|
22
|
-
skipExisting,
|
|
23
|
-
};
|
|
24
|
-
if (!command) {
|
|
25
|
-
return { type: 'new', ...options };
|
|
26
|
-
}
|
|
27
|
-
switch (command) {
|
|
28
|
-
case 'new':
|
|
29
|
-
return { type: 'new', projectName, ...options };
|
|
30
|
-
case '.':
|
|
31
|
-
case 'init':
|
|
32
|
-
return { type: 'init', ...options };
|
|
33
|
-
case 'doctor':
|
|
34
|
-
return { type: 'doctor' };
|
|
35
|
-
case 'publish':
|
|
36
|
-
return { type: 'publish' };
|
|
37
|
-
default:
|
|
38
|
-
return { type: 'unknown', command };
|
|
39
|
-
}
|
|
40
|
-
};
|
package/cli/args/index.d.ts
DELETED
package/cli/args/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './args.js';
|
package/cli/args/types.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export type VyriyCliCommand = {
|
|
2
|
-
readonly type: 'new';
|
|
3
|
-
readonly projectName?: string;
|
|
4
|
-
readonly dryRun: boolean;
|
|
5
|
-
readonly install: boolean;
|
|
6
|
-
readonly yes: boolean;
|
|
7
|
-
readonly overwrite: boolean;
|
|
8
|
-
readonly verify: boolean;
|
|
9
|
-
readonly skipExisting: boolean;
|
|
10
|
-
} | {
|
|
11
|
-
readonly type: 'init';
|
|
12
|
-
readonly dryRun: boolean;
|
|
13
|
-
readonly install: boolean;
|
|
14
|
-
readonly yes: boolean;
|
|
15
|
-
readonly overwrite: boolean;
|
|
16
|
-
readonly verify: boolean;
|
|
17
|
-
readonly skipExisting: boolean;
|
|
18
|
-
} | {
|
|
19
|
-
readonly type: 'doctor' | 'help' | 'publish' | 'version';
|
|
20
|
-
} | {
|
|
21
|
-
readonly type: 'unknown';
|
|
22
|
-
readonly command: string;
|
|
23
|
-
};
|
|
24
|
-
export type ParseArgs = (args: readonly string[]) => VyriyCliCommand;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { createDoctorReport, printDoctorReport } from '../../doctor/index.js';
|
|
2
|
-
export const runDoctorCommand = async ({ output = console } = {}) => {
|
|
3
|
-
const report = await createDoctorReport();
|
|
4
|
-
output.log(printDoctorReport(report));
|
|
5
|
-
return {
|
|
6
|
-
code: report.hasErrors ? 1 : 0,
|
|
7
|
-
checks: report.checks,
|
|
8
|
-
};
|
|
9
|
-
};
|
package/commands/doctor/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './doctor.js';
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { DoctorCheck } from '../../doctor/index.js';
|
|
2
|
-
export type RunDoctorCommandOptions = {
|
|
3
|
-
readonly output?: Pick<typeof console, 'log' | 'error'>;
|
|
4
|
-
};
|
|
5
|
-
export type RunDoctorCommand = (options?: RunDoctorCommandOptions) => Promise<{
|
|
6
|
-
readonly code: number;
|
|
7
|
-
readonly checks: readonly DoctorCheck[];
|
|
8
|
-
}>;
|
package/commands/init/index.d.ts
DELETED
package/commands/init/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './init.js';
|
package/commands/init/init.d.ts
DELETED
package/commands/init/init.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import { cwd as getCwd } from 'node:process';
|
|
3
|
-
import { runNewCommand } from '../new/index.js';
|
|
4
|
-
export const runInitCommand = async ({ cwd = getCwd(), ...options } = {}) => runNewCommand({
|
|
5
|
-
...options,
|
|
6
|
-
projectName: path.basename(cwd),
|
|
7
|
-
});
|
package/commands/init/types.d.ts
DELETED
package/commands/new/index.d.ts
DELETED
package/commands/new/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './new.js';
|
package/commands/new/new.d.ts
DELETED
package/commands/new/new.js
DELETED
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
import { stdin, stdout } from 'node:process';
|
|
2
|
-
import { createInterface } from 'node:readline/promises';
|
|
3
|
-
import { createDoctorReport, printDoctorReport } from '../../doctor/index.js';
|
|
4
|
-
import { createFilePlan, printFilePlan, writeFilePlan } from '../../file-plan/index.js';
|
|
5
|
-
import { createProjectFiles } from '../../presets/index.js';
|
|
6
|
-
import { askProjectPlan as askProjectPlanDefault } from '../../prompts/project-plan/index.js';
|
|
7
|
-
import { createProjectPlanFromPreset, printProjectPlan } from '../../project-plan/index.js';
|
|
8
|
-
import { runCommand } from '../../shared/index.js';
|
|
9
|
-
const defaultYesPreset = 'empty';
|
|
10
|
-
const getConflicts = (filePlan) => filePlan.filter((item) => item.status === 'conflict');
|
|
11
|
-
const logConflicts = (output, conflicts, method) => {
|
|
12
|
-
output[method]('\nExisting files found:\n');
|
|
13
|
-
for (const conflict of conflicts) {
|
|
14
|
-
output[method](` ! ${conflict.path}`);
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
const printConflictPrompt = (output) => {
|
|
18
|
-
output.log('\nWhat should Vyriy do?');
|
|
19
|
-
output.log(' 1. overwrite existing files');
|
|
20
|
-
output.log(' 2. skip existing files');
|
|
21
|
-
output.log(' 3. abort');
|
|
22
|
-
};
|
|
23
|
-
const failOnNonInteractiveConflicts = (output, conflicts) => {
|
|
24
|
-
logConflicts(output, conflicts, 'error');
|
|
25
|
-
output.error('\nCannot continue in non-interactive mode without a conflict strategy.\n');
|
|
26
|
-
output.error('Use one of:\n\n vyriy --overwrite\n vyriy --skip-existing\n vyriy --dry-run');
|
|
27
|
-
return 1;
|
|
28
|
-
};
|
|
29
|
-
const createResolvedFilePlan = async (plan, projectFiles, resolution) => createFilePlan(plan.targetDirectory, projectFiles, {
|
|
30
|
-
overwrite: resolution === 'overwrite',
|
|
31
|
-
skipExisting: resolution === 'skip',
|
|
32
|
-
});
|
|
33
|
-
const formatCommand = (command, args) => [command, ...args].join(' ');
|
|
34
|
-
const printFailedPostGenerationCommand = ({ args, command, intro, output, projectDirectory, }) => {
|
|
35
|
-
const commandText = formatCommand(command, args);
|
|
36
|
-
output.error(`\n${intro}\n`);
|
|
37
|
-
output.error(`Failed command:\n ${commandText}\n`);
|
|
38
|
-
output.error(`Project directory:\n ${projectDirectory}\n`);
|
|
39
|
-
output.error(`You can inspect it and run manually:\n cd ${projectDirectory}\n ${commandText}`);
|
|
40
|
-
};
|
|
41
|
-
const runPostGenerationCommands = async ({ install, output, projectDirectory, verify, }) => {
|
|
42
|
-
if (!install) {
|
|
43
|
-
output.log('Installing dependencies... SKIPPED');
|
|
44
|
-
output.log('Running checks... SKIPPED');
|
|
45
|
-
output.log('\nProject files were created.');
|
|
46
|
-
return 0;
|
|
47
|
-
}
|
|
48
|
-
try {
|
|
49
|
-
await runCommand({
|
|
50
|
-
args: ['install'],
|
|
51
|
-
command: 'yarn',
|
|
52
|
-
cwd: projectDirectory,
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
catch {
|
|
56
|
-
printFailedPostGenerationCommand({
|
|
57
|
-
args: ['install'],
|
|
58
|
-
command: 'yarn',
|
|
59
|
-
intro: 'Project files were created, but dependency installation failed.',
|
|
60
|
-
output,
|
|
61
|
-
projectDirectory,
|
|
62
|
-
});
|
|
63
|
-
return 1;
|
|
64
|
-
}
|
|
65
|
-
output.log('Installing dependencies... OK');
|
|
66
|
-
if (!verify) {
|
|
67
|
-
output.log('Running checks... SKIPPED');
|
|
68
|
-
output.log('\nProject files were created and dependencies were installed.');
|
|
69
|
-
return 0;
|
|
70
|
-
}
|
|
71
|
-
try {
|
|
72
|
-
await runCommand({
|
|
73
|
-
args: ['fix'],
|
|
74
|
-
command: 'yarn',
|
|
75
|
-
cwd: projectDirectory,
|
|
76
|
-
});
|
|
77
|
-
await runCommand({
|
|
78
|
-
args: ['check'],
|
|
79
|
-
command: 'yarn',
|
|
80
|
-
cwd: projectDirectory,
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
catch {
|
|
84
|
-
printFailedPostGenerationCommand({
|
|
85
|
-
args: ['check'],
|
|
86
|
-
command: 'yarn',
|
|
87
|
-
intro: 'Project files were created and dependencies were installed, but verification failed.',
|
|
88
|
-
output,
|
|
89
|
-
projectDirectory,
|
|
90
|
-
});
|
|
91
|
-
return 1;
|
|
92
|
-
}
|
|
93
|
-
output.log('Running checks... OK');
|
|
94
|
-
output.log('\nProject is ready.');
|
|
95
|
-
return 0;
|
|
96
|
-
};
|
|
97
|
-
const resolveInteractiveConflicts = async (plan, projectFiles, output, conflicts, askConflictResolution) => {
|
|
98
|
-
logConflicts(output, conflicts, 'log');
|
|
99
|
-
printConflictPrompt(output);
|
|
100
|
-
const resolution = await askConflictResolution();
|
|
101
|
-
if (resolution === 'abort') {
|
|
102
|
-
output.log('Project generation aborted.');
|
|
103
|
-
return { result: 1, status: 'failed' };
|
|
104
|
-
}
|
|
105
|
-
const filePlan = await createResolvedFilePlan(plan, projectFiles, resolution);
|
|
106
|
-
if (getConflicts(filePlan).length > 0) {
|
|
107
|
-
output.error('Cannot continue with unresolved file conflicts.');
|
|
108
|
-
return { result: 1, status: 'failed' };
|
|
109
|
-
}
|
|
110
|
-
return { filePlan, status: 'resolved' };
|
|
111
|
-
};
|
|
112
|
-
export const askConflictResolutionDefault = async () => {
|
|
113
|
-
const readline = createInterface({ input: stdin, output: stdout });
|
|
114
|
-
try {
|
|
115
|
-
const answer = (await readline.question('What should Vyriy do?\n\n 1. overwrite existing files,\n\n 2. skip existing files,\n\n 3. abort (abort): '))
|
|
116
|
-
.trim()
|
|
117
|
-
.toLowerCase();
|
|
118
|
-
if (answer === '1' || answer === 'overwrite') {
|
|
119
|
-
return 'overwrite';
|
|
120
|
-
}
|
|
121
|
-
if (answer === '2' || answer === 'skip') {
|
|
122
|
-
return 'skip';
|
|
123
|
-
}
|
|
124
|
-
return 'abort';
|
|
125
|
-
}
|
|
126
|
-
finally {
|
|
127
|
-
readline.close();
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
export const runNewCommand = async ({ askConflictResolution = askConflictResolutionDefault, askProjectPlan = askProjectPlanDefault, dryRun = false, install = true, output = console, overwrite = false, projectName = 'my-app', skipExisting = false, verify = true, yes = false, } = {}) => {
|
|
131
|
-
if (overwrite && skipExisting) {
|
|
132
|
-
output.error('Cannot use --overwrite and --skip-existing together.');
|
|
133
|
-
return 1;
|
|
134
|
-
}
|
|
135
|
-
const report = await createDoctorReport();
|
|
136
|
-
output.log(printDoctorReport(report));
|
|
137
|
-
if (report.hasErrors) {
|
|
138
|
-
output.error('\nPlease install Node.js 24+ and run the command again.');
|
|
139
|
-
return 1;
|
|
140
|
-
}
|
|
141
|
-
const plan = yes
|
|
142
|
-
? createProjectPlanFromPreset({
|
|
143
|
-
apiStyle: 'rest',
|
|
144
|
-
ciProvider: 'none',
|
|
145
|
-
description: 'Calm cloud-ready application.',
|
|
146
|
-
packageScope: `@${projectName}`,
|
|
147
|
-
preset: defaultYesPreset,
|
|
148
|
-
projectName,
|
|
149
|
-
targetDirectory: projectName,
|
|
150
|
-
})
|
|
151
|
-
: await askProjectPlan({
|
|
152
|
-
defaults: {
|
|
153
|
-
projectName,
|
|
154
|
-
targetDirectory: projectName,
|
|
155
|
-
},
|
|
156
|
-
});
|
|
157
|
-
if (!plan) {
|
|
158
|
-
output.log('Project planning cancelled.');
|
|
159
|
-
return 1;
|
|
160
|
-
}
|
|
161
|
-
output.log(`\n${printProjectPlan(plan)}`);
|
|
162
|
-
const projectFiles = createProjectFiles(plan);
|
|
163
|
-
let filePlan = await createFilePlan(plan.targetDirectory, projectFiles, { overwrite, skipExisting });
|
|
164
|
-
let conflicts = filePlan.filter((item) => item.status === 'conflict');
|
|
165
|
-
output.log(`\n${printFilePlan(filePlan)}`);
|
|
166
|
-
if (dryRun) {
|
|
167
|
-
output.log('\nNo files will be written in dry-run mode.');
|
|
168
|
-
return conflicts.length > 0 ? 1 : 0;
|
|
169
|
-
}
|
|
170
|
-
if (conflicts.length > 0 && yes) {
|
|
171
|
-
return failOnNonInteractiveConflicts(output, conflicts);
|
|
172
|
-
}
|
|
173
|
-
if (conflicts.length > 0) {
|
|
174
|
-
const resolved = await resolveInteractiveConflicts(plan, projectFiles, output, conflicts, askConflictResolution);
|
|
175
|
-
if (resolved.status === 'failed') {
|
|
176
|
-
return resolved.result;
|
|
177
|
-
}
|
|
178
|
-
filePlan = resolved.filePlan;
|
|
179
|
-
output.log(`\n${printFilePlan(resolved.filePlan)}`);
|
|
180
|
-
}
|
|
181
|
-
await writeFilePlan(plan.targetDirectory, filePlan);
|
|
182
|
-
output.log('\nCreating project files... OK');
|
|
183
|
-
return runPostGenerationCommands({
|
|
184
|
-
install,
|
|
185
|
-
output,
|
|
186
|
-
projectDirectory: plan.targetDirectory,
|
|
187
|
-
verify: install && verify,
|
|
188
|
-
});
|
|
189
|
-
};
|
package/commands/new/types.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { PromptProjectPlan } from '../../prompts/project-plan/index.js';
|
|
2
|
-
export type ConflictResolution = 'overwrite' | 'skip' | 'abort';
|
|
3
|
-
export type RunNewCommandOptions = {
|
|
4
|
-
readonly projectName?: string;
|
|
5
|
-
readonly askProjectPlan?: PromptProjectPlan;
|
|
6
|
-
readonly askConflictResolution?: () => Promise<ConflictResolution>;
|
|
7
|
-
readonly output?: Pick<typeof console, 'log' | 'error'>;
|
|
8
|
-
readonly dryRun?: boolean;
|
|
9
|
-
readonly install?: boolean;
|
|
10
|
-
readonly yes?: boolean;
|
|
11
|
-
readonly overwrite?: boolean;
|
|
12
|
-
readonly verify?: boolean;
|
|
13
|
-
readonly skipExisting?: boolean;
|
|
14
|
-
};
|
|
15
|
-
export type RunNewCommand = (options?: RunNewCommandOptions) => Promise<number>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './publish.js';
|
package/doctor/checkCorepack.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { execCommand as execCommandDefault } from '../shared/index.js';
|
|
2
|
-
export const checkCorepack = async ({ execCommand = execCommandDefault, } = {}) => {
|
|
3
|
-
try {
|
|
4
|
-
const version = await execCommand('corepack', ['--version']);
|
|
5
|
-
return {
|
|
6
|
-
name: 'corepack',
|
|
7
|
-
label: 'Corepack',
|
|
8
|
-
group: 'Package manager',
|
|
9
|
-
level: 'ok',
|
|
10
|
-
version,
|
|
11
|
-
message: 'Corepack available',
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
catch {
|
|
15
|
-
return {
|
|
16
|
-
name: 'corepack',
|
|
17
|
-
label: 'Corepack',
|
|
18
|
-
group: 'Package manager',
|
|
19
|
-
level: 'warning',
|
|
20
|
-
message: 'Corepack was not found',
|
|
21
|
-
detail: 'Yarn fixes cannot be run automatically without Corepack.',
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
};
|
package/doctor/checkGit.d.ts
DELETED
package/doctor/checkGit.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { execCommand as execCommandDefault } from '../shared/index.js';
|
|
2
|
-
export const checkGit = async ({ execCommand = execCommandDefault } = {}) => {
|
|
3
|
-
try {
|
|
4
|
-
await execCommand('git', ['--version']);
|
|
5
|
-
return {
|
|
6
|
-
name: 'git',
|
|
7
|
-
label: 'Git',
|
|
8
|
-
group: 'Git',
|
|
9
|
-
level: 'ok',
|
|
10
|
-
message: 'Git available',
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
catch {
|
|
14
|
-
return {
|
|
15
|
-
name: 'git',
|
|
16
|
-
label: 'Git',
|
|
17
|
-
group: 'Git',
|
|
18
|
-
level: 'warning',
|
|
19
|
-
message: 'Git was not found',
|
|
20
|
-
detail: 'Git initialization will be skipped.',
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { getMajorVersion } from '../shared/index.js';
|
|
2
|
-
export const checkNodeVersion = ({ minimumMajor = 24, version = process.version, } = {}) => {
|
|
3
|
-
const normalizedVersion = version.replace(/^v/, '');
|
|
4
|
-
const majorVersion = getMajorVersion(normalizedVersion);
|
|
5
|
-
if (majorVersion !== undefined && majorVersion >= minimumMajor) {
|
|
6
|
-
return {
|
|
7
|
-
name: 'node',
|
|
8
|
-
label: 'Node.js',
|
|
9
|
-
group: 'Runtime',
|
|
10
|
-
level: 'ok',
|
|
11
|
-
version: normalizedVersion,
|
|
12
|
-
message: `Node.js ${normalizedVersion}`,
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
return {
|
|
16
|
-
name: 'node',
|
|
17
|
-
label: 'Node.js',
|
|
18
|
-
group: 'Runtime',
|
|
19
|
-
level: 'error',
|
|
20
|
-
version: normalizedVersion,
|
|
21
|
-
message: `Node.js ${normalizedVersion} detected`,
|
|
22
|
-
detail: `Vyriy requires Node.js ${minimumMajor} or newer.`,
|
|
23
|
-
};
|
|
24
|
-
};
|
package/doctor/checkYarn.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { DoctorCheck, DoctorCheckOptions } from './types.js';
|
|
2
|
-
export declare const yarnStableFix: {
|
|
3
|
-
readonly label: "Enable Yarn using Corepack";
|
|
4
|
-
readonly command: "corepack enable\ncorepack prepare yarn@stable --activate";
|
|
5
|
-
readonly safeToRun: true;
|
|
6
|
-
};
|
|
7
|
-
export declare const checkYarn: ({ execCommand, minimumMajor, version, }?: DoctorCheckOptions & {
|
|
8
|
-
readonly minimumMajor?: number;
|
|
9
|
-
readonly version?: string;
|
|
10
|
-
}) => Promise<DoctorCheck>;
|
package/doctor/checkYarn.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { execCommand as execCommandDefault, getMajorVersion } from '../shared/index.js';
|
|
2
|
-
export const yarnStableFix = {
|
|
3
|
-
label: 'Enable Yarn using Corepack',
|
|
4
|
-
command: 'corepack enable\ncorepack prepare yarn@stable --activate',
|
|
5
|
-
safeToRun: true,
|
|
6
|
-
};
|
|
7
|
-
export const checkYarn = async ({ execCommand = execCommandDefault, minimumMajor = 4, version, } = {}) => {
|
|
8
|
-
let currentVersion = version;
|
|
9
|
-
try {
|
|
10
|
-
currentVersion ??= await execCommand('yarn', ['--version']);
|
|
11
|
-
}
|
|
12
|
-
catch {
|
|
13
|
-
return {
|
|
14
|
-
name: 'yarn',
|
|
15
|
-
label: 'Yarn',
|
|
16
|
-
group: 'Package manager',
|
|
17
|
-
level: 'warning',
|
|
18
|
-
message: 'Yarn was not found',
|
|
19
|
-
detail: 'Vyriy uses Yarn 4 for generated projects.',
|
|
20
|
-
fix: yarnStableFix,
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
const normalizedVersion = currentVersion.trim();
|
|
24
|
-
const majorVersion = getMajorVersion(normalizedVersion);
|
|
25
|
-
if (majorVersion !== undefined && majorVersion >= minimumMajor) {
|
|
26
|
-
return {
|
|
27
|
-
name: 'yarn',
|
|
28
|
-
label: 'Yarn',
|
|
29
|
-
group: 'Package manager',
|
|
30
|
-
level: 'ok',
|
|
31
|
-
version: normalizedVersion,
|
|
32
|
-
message: `Yarn ${normalizedVersion}`,
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
return {
|
|
36
|
-
name: 'yarn',
|
|
37
|
-
label: 'Yarn',
|
|
38
|
-
group: 'Package manager',
|
|
39
|
-
level: 'warning',
|
|
40
|
-
version: normalizedVersion,
|
|
41
|
-
message: `Yarn ${normalizedVersion} detected`,
|
|
42
|
-
detail: `Vyriy recommends Yarn ${minimumMajor}.`,
|
|
43
|
-
fix: yarnStableFix,
|
|
44
|
-
};
|
|
45
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { checkCorepack } from './checkCorepack.js';
|
|
2
|
-
import { checkGit } from './checkGit.js';
|
|
3
|
-
import { checkNodeVersion } from './checkNodeVersion.js';
|
|
4
|
-
import { checkYarn } from './checkYarn.js';
|
|
5
|
-
export const createDoctorReport = async (options = {}) => {
|
|
6
|
-
const checks = [
|
|
7
|
-
checkNodeVersion(),
|
|
8
|
-
await checkCorepack(options),
|
|
9
|
-
await checkYarn(options),
|
|
10
|
-
await checkGit(options),
|
|
11
|
-
];
|
|
12
|
-
return {
|
|
13
|
-
checks,
|
|
14
|
-
hasErrors: checks.some((check) => check.level === 'error'),
|
|
15
|
-
hasWarnings: checks.some((check) => check.level === 'warning'),
|
|
16
|
-
};
|
|
17
|
-
};
|
package/doctor/index.d.ts
DELETED
package/doctor/index.js
DELETED