vyriy 0.3.9 → 0.4.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 (189) hide show
  1. package/README.md +74 -179
  2. package/bin/vyriy.js +2 -2
  3. package/cli/args.js +29 -0
  4. package/cli/cli.d.ts +2 -2
  5. package/cli/cli.js +18 -69
  6. package/cli/index.d.ts +1 -1
  7. package/cli/index.js +1 -1
  8. package/cli/types.d.ts +12 -3
  9. package/commands/check-env.d.ts +2 -0
  10. package/commands/check-env.js +65 -0
  11. package/commands/create/index.d.ts +2 -0
  12. package/commands/create/index.js +121 -0
  13. package/commands/create/plan/index.d.ts +4 -0
  14. package/commands/create/plan/index.js +3 -0
  15. package/commands/create/plan/plan.d.ts +9 -0
  16. package/commands/create/plan/plan.js +34 -0
  17. package/commands/create/plan/question.d.ts +2 -0
  18. package/commands/create/plan/question.js +25 -0
  19. package/commands/create/plan/types.d.ts +14 -0
  20. package/commands/create/preset/api.d.ts +2 -0
  21. package/commands/create/preset/api.js +16 -0
  22. package/commands/create/preset/base.d.ts +2 -0
  23. package/commands/create/preset/base.js +195 -0
  24. package/commands/create/preset/gql.d.ts +2 -0
  25. package/commands/create/preset/gql.js +16 -0
  26. package/commands/create/preset/index.d.ts +12 -0
  27. package/commands/create/preset/index.js +14 -0
  28. package/commands/create/preset/library.d.ts +2 -0
  29. package/commands/create/preset/library.js +227 -0
  30. package/commands/create/preset/mfe.d.ts +2 -0
  31. package/commands/create/preset/mfe.js +16 -0
  32. package/commands/create/preset/rest.d.ts +2 -0
  33. package/commands/create/preset/rest.js +16 -0
  34. package/commands/create/preset/spa.d.ts +2 -0
  35. package/commands/create/preset/spa.js +16 -0
  36. package/commands/create/preset/ssg.d.ts +2 -0
  37. package/commands/create/preset/ssg.js +16 -0
  38. package/commands/create/preset/ssr.d.ts +2 -0
  39. package/commands/create/preset/ssr.js +16 -0
  40. package/commands/create/preset/types.d.ts +15 -0
  41. package/commands/create/prompt/conflict-strategy.d.ts +5 -0
  42. package/commands/create/prompt/conflict-strategy.js +22 -0
  43. package/commands/create/prompt/index.d.ts +7 -0
  44. package/commands/create/prompt/index.js +6 -0
  45. package/commands/create/prompt/preset.d.ts +4 -0
  46. package/commands/create/prompt/preset.js +11 -0
  47. package/commands/create/prompt/prompt.d.ts +2 -0
  48. package/commands/create/prompt/prompt.js +4 -0
  49. package/commands/create/prompt/provider.d.ts +2 -0
  50. package/commands/create/prompt/provider.js +13 -0
  51. package/commands/create/prompt/resolve-option.d.ts +6 -0
  52. package/commands/create/prompt/resolve-option.js +8 -0
  53. package/commands/create/prompt/scope.d.ts +2 -0
  54. package/commands/create/prompt/scope.js +2 -0
  55. package/commands/create/prompt/types.d.ts +4 -0
  56. package/commands/dist.d.ts +2 -0
  57. package/commands/{publish/publish.js → dist.js} +8 -8
  58. package/commands/help.d.ts +3 -0
  59. package/commands/help.js +24 -0
  60. package/commands/index.d.ts +5 -0
  61. package/commands/index.js +5 -0
  62. package/commands/{publish/types.d.ts → types.d.ts} +18 -4
  63. package/commands/version.d.ts +2 -0
  64. package/commands/version.js +6 -0
  65. package/package.json +280 -551
  66. package/checks/node/index.d.ts +0 -2
  67. package/checks/node/index.js +0 -1
  68. package/checks/node/node.d.ts +0 -2
  69. package/checks/node/node.js +0 -22
  70. package/checks/node/types.d.ts +0 -11
  71. package/checks/yarn/index.d.ts +0 -2
  72. package/checks/yarn/index.js +0 -1
  73. package/checks/yarn/types.d.ts +0 -7
  74. package/checks/yarn/yarn.d.ts +0 -2
  75. package/checks/yarn/yarn.js +0 -40
  76. package/cli/args/args.js +0 -40
  77. package/cli/args/index.d.ts +0 -2
  78. package/cli/args/index.js +0 -1
  79. package/cli/args/types.d.ts +0 -24
  80. package/commands/doctor/doctor.d.ts +0 -2
  81. package/commands/doctor/doctor.js +0 -9
  82. package/commands/doctor/index.d.ts +0 -2
  83. package/commands/doctor/index.js +0 -1
  84. package/commands/doctor/types.d.ts +0 -8
  85. package/commands/init/index.d.ts +0 -2
  86. package/commands/init/index.js +0 -1
  87. package/commands/init/init.d.ts +0 -2
  88. package/commands/init/init.js +0 -7
  89. package/commands/init/types.d.ts +0 -5
  90. package/commands/new/index.d.ts +0 -2
  91. package/commands/new/index.js +0 -1
  92. package/commands/new/new.d.ts +0 -3
  93. package/commands/new/new.js +0 -189
  94. package/commands/new/types.d.ts +0 -15
  95. package/commands/publish/index.d.ts +0 -2
  96. package/commands/publish/index.js +0 -1
  97. package/commands/publish/publish.d.ts +0 -2
  98. package/doctor/checkCorepack.d.ts +0 -2
  99. package/doctor/checkCorepack.js +0 -24
  100. package/doctor/checkGit.d.ts +0 -2
  101. package/doctor/checkGit.js +0 -23
  102. package/doctor/checkNodeVersion.d.ts +0 -5
  103. package/doctor/checkNodeVersion.js +0 -24
  104. package/doctor/checkYarn.d.ts +0 -10
  105. package/doctor/checkYarn.js +0 -45
  106. package/doctor/createDoctorReport.d.ts +0 -2
  107. package/doctor/createDoctorReport.js +0 -17
  108. package/doctor/index.d.ts +0 -7
  109. package/doctor/index.js +0 -6
  110. package/doctor/printDoctorReport.d.ts +0 -2
  111. package/doctor/printDoctorReport.js +0 -42
  112. package/doctor/types.d.ts +0 -25
  113. package/file-plan/createFilePlan.d.ts +0 -4
  114. package/file-plan/createFilePlan.js +0 -29
  115. package/file-plan/index.d.ts +0 -4
  116. package/file-plan/index.js +0 -3
  117. package/file-plan/printFilePlan.d.ts +0 -2
  118. package/file-plan/printFilePlan.js +0 -44
  119. package/file-plan/types.d.ts +0 -12
  120. package/file-plan/writeFilePlan.d.ts +0 -2
  121. package/file-plan/writeFilePlan.js +0 -12
  122. package/index.d.ts +0 -12
  123. package/index.js +0 -12
  124. package/presets/agentsTemplate.d.ts +0 -1
  125. package/presets/agentsTemplate.js +0 -105
  126. package/presets/base/createBaseFiles.d.ts +0 -3
  127. package/presets/base/createBaseFiles.js +0 -307
  128. package/presets/config.d.ts +0 -28
  129. package/presets/config.js +0 -7
  130. package/presets/createProjectFiles.d.ts +0 -2
  131. package/presets/createProjectFiles.js +0 -8
  132. package/presets/index.d.ts +0 -2
  133. package/presets/index.js +0 -1
  134. package/presets/library/createLibraryUiFiles.d.ts +0 -3
  135. package/presets/library/createLibraryUiFiles.js +0 -127
  136. package/presets/packages/createPackageFiles.d.ts +0 -3
  137. package/presets/packages/createPackageFiles.js +0 -39
  138. package/presets/packages/createPackageManifest.d.ts +0 -7
  139. package/presets/packages/createPackageManifest.js +0 -13
  140. package/presets/types.d.ts +0 -3
  141. package/presets/workspaces/createWorkspaceFiles.d.ts +0 -3
  142. package/presets/workspaces/createWorkspaceFiles.js +0 -98
  143. package/project-plan/api/api.d.ts +0 -6
  144. package/project-plan/api/api.js +0 -44
  145. package/project-plan/api/index.d.ts +0 -2
  146. package/project-plan/api/index.js +0 -1
  147. package/project-plan/api/types.d.ts +0 -11
  148. package/project-plan/ci/ci.d.ts +0 -3
  149. package/project-plan/ci/ci.js +0 -20
  150. package/project-plan/ci/index.d.ts +0 -2
  151. package/project-plan/ci/index.js +0 -1
  152. package/project-plan/ci/types.d.ts +0 -6
  153. package/project-plan/create/create.d.ts +0 -2
  154. package/project-plan/create/create.js +0 -129
  155. package/project-plan/create/index.d.ts +0 -2
  156. package/project-plan/create/index.js +0 -1
  157. package/project-plan/create/types.d.ts +0 -13
  158. package/project-plan/index.d.ts +0 -6
  159. package/project-plan/index.js +0 -5
  160. package/project-plan/kind/index.d.ts +0 -2
  161. package/project-plan/kind/index.js +0 -1
  162. package/project-plan/kind/kind.d.ts +0 -2
  163. package/project-plan/kind/kind.js +0 -1
  164. package/project-plan/kind/types.d.ts +0 -2
  165. package/project-plan/print/index.d.ts +0 -2
  166. package/project-plan/print/index.js +0 -1
  167. package/project-plan/print/print.d.ts +0 -2
  168. package/project-plan/print/print.js +0 -47
  169. package/project-plan/print/types.d.ts +0 -2
  170. package/project-plan/types.d.ts +0 -46
  171. package/prompts/project-plan/index.d.ts +0 -2
  172. package/prompts/project-plan/index.js +0 -1
  173. package/prompts/project-plan/project-plan.d.ts +0 -2
  174. package/prompts/project-plan/project-plan.js +0 -198
  175. package/prompts/project-plan/types.d.ts +0 -18
  176. package/shared/commandExists.d.ts +0 -2
  177. package/shared/commandExists.js +0 -10
  178. package/shared/execCommand.d.ts +0 -2
  179. package/shared/execCommand.js +0 -7
  180. package/shared/fileExists.d.ts +0 -2
  181. package/shared/fileExists.js +0 -10
  182. package/shared/index.d.ts +0 -6
  183. package/shared/index.js +0 -5
  184. package/shared/runCommand.d.ts +0 -9
  185. package/shared/runCommand.js +0 -34
  186. package/shared/semver.d.ts +0 -1
  187. package/shared/semver.js +0 -4
  188. package/shared/types.d.ts +0 -12
  189. /package/cli/{args/args.d.ts → args.d.ts} +0 -0
@@ -1,2 +0,0 @@
1
- export * from './node.js';
2
- export type * from './types.js';
@@ -1 +0,0 @@
1
- export * from './node.js';
@@ -1,2 +0,0 @@
1
- import { CheckNodeVersion } from './types.js';
2
- export declare const checkNodeVersion: CheckNodeVersion;
@@ -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
- };
@@ -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;
@@ -1,2 +0,0 @@
1
- export * from './yarn.js';
2
- export type * from './types.js';
@@ -1 +0,0 @@
1
- export * from './yarn.js';
@@ -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>;
@@ -1,2 +0,0 @@
1
- import { CheckYarnVersion } from './types.js';
2
- export declare const checkYarnVersion: CheckYarnVersion;
@@ -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
- };
@@ -1,2 +0,0 @@
1
- export * from './args.js';
2
- export type * from './types.js';
package/cli/args/index.js DELETED
@@ -1 +0,0 @@
1
- export * from './args.js';
@@ -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,2 +0,0 @@
1
- import { RunDoctorCommand } from './types.js';
2
- export declare const runDoctorCommand: RunDoctorCommand;
@@ -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
- };
@@ -1,2 +0,0 @@
1
- export * from './doctor.js';
2
- export type * from './types.js';
@@ -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
- }>;
@@ -1,2 +0,0 @@
1
- export * from './init.js';
2
- export type * from './types.js';
@@ -1 +0,0 @@
1
- export * from './init.js';
@@ -1,2 +0,0 @@
1
- import { RunInitCommand } from './types.js';
2
- export declare const runInitCommand: RunInitCommand;
@@ -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
- });
@@ -1,5 +0,0 @@
1
- import { RunNewCommandOptions } from '../new/index.js';
2
- export type RunInitCommandOptions = Omit<RunNewCommandOptions, 'projectName'> & {
3
- readonly cwd?: string;
4
- };
5
- export type RunInitCommand = (options?: RunInitCommandOptions) => Promise<number>;
@@ -1,2 +0,0 @@
1
- export * from './new.js';
2
- export type * from './types.js';
@@ -1 +0,0 @@
1
- export * from './new.js';
@@ -1,3 +0,0 @@
1
- import { ConflictResolution, RunNewCommand } from './types.js';
2
- export declare const askConflictResolutionDefault: () => Promise<ConflictResolution>;
3
- export declare const runNewCommand: RunNewCommand;
@@ -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
- };
@@ -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,2 +0,0 @@
1
- export * from './publish.js';
2
- export type * from './types.js';
@@ -1 +0,0 @@
1
- export * from './publish.js';
@@ -1,2 +0,0 @@
1
- import type { RunPublishCommand } from './types.js';
2
- export declare const runPublishCommand: RunPublishCommand;
@@ -1,2 +0,0 @@
1
- import { DoctorCheck, DoctorCheckOptions } from './types.js';
2
- export declare const checkCorepack: ({ execCommand, }?: DoctorCheckOptions) => Promise<DoctorCheck>;
@@ -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
- };
@@ -1,2 +0,0 @@
1
- import { DoctorCheck, DoctorCheckOptions } from './types.js';
2
- export declare const checkGit: ({ execCommand }?: DoctorCheckOptions) => Promise<DoctorCheck>;
@@ -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,5 +0,0 @@
1
- import { DoctorCheck } from './types.js';
2
- export declare const checkNodeVersion: ({ minimumMajor, version, }?: {
3
- readonly minimumMajor?: number;
4
- readonly version?: string;
5
- }) => DoctorCheck;
@@ -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
- };
@@ -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>;
@@ -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,2 +0,0 @@
1
- import { DoctorCheckOptions, DoctorReport } from './types.js';
2
- export declare const createDoctorReport: (options?: DoctorCheckOptions) => Promise<DoctorReport>;
@@ -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
@@ -1,7 +0,0 @@
1
- export * from './checkCorepack.js';
2
- export * from './checkGit.js';
3
- export * from './checkNodeVersion.js';
4
- export * from './checkYarn.js';
5
- export * from './createDoctorReport.js';
6
- export * from './printDoctorReport.js';
7
- export type * from './types.js';