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
@@ -0,0 +1,2 @@
1
+ import { Preset } from './types.js';
2
+ export declare const ssr: Preset;
@@ -0,0 +1,16 @@
1
+ import { base } from './base.js';
2
+ export const ssr = {
3
+ files: (options) => ({
4
+ ...base.files(options),
5
+ }),
6
+ ci: {
7
+ github: {
8
+ '.gitlab-ci.yml': 'code',
9
+ },
10
+ },
11
+ deploy: {
12
+ docker: {
13
+ Dockerfile: 'code',
14
+ },
15
+ },
16
+ };
@@ -0,0 +1,15 @@
1
+ import type { PlanResult } from '../plan/types.js';
2
+ export type FileMap = Record<string, string>;
3
+ export type CiProvider = 'gitlab' | 'github';
4
+ export type DeployProvider = 'aws' | 'docker';
5
+ export type Preset = {
6
+ files: (options: PlanResult) => FileMap;
7
+ ci: Partial<Record<CiProvider, FileMap>>;
8
+ deploy: Partial<Record<DeployProvider, FileMap>>;
9
+ };
10
+ export type PresetKey = 'base' | 'library' | 'api' | 'ssr' | 'rest' | 'gql' | 'ssg' | 'spa' | 'mfe';
11
+ export type Presets = Partial<Record<PresetKey, {
12
+ name: string;
13
+ description: string;
14
+ preset: Preset;
15
+ }>>;
@@ -0,0 +1,5 @@
1
+ export type ConflictStrategy = {
2
+ readonly overwrite: boolean;
3
+ readonly skipExisting: boolean;
4
+ };
5
+ export declare const conflictStrategy: () => Promise<ConflictStrategy | undefined>;
@@ -0,0 +1,22 @@
1
+ import { stdin, stdout } from 'node:process';
2
+ import { createInterface } from 'node:readline/promises';
3
+ export const conflictStrategy = async () => {
4
+ console.log('\nWhat should Vyriy do?\n');
5
+ console.log(' 1. overwrite existing files');
6
+ console.log(' 2. skip existing files');
7
+ console.log(' 3. abort');
8
+ const readline = createInterface({ input: stdin, output: stdout });
9
+ try {
10
+ const answer = (await readline.question('\nWhat should Vyriy do? (abort): ')).trim().toLowerCase();
11
+ if (answer === '1' || answer === 'overwrite') {
12
+ return { overwrite: true, skipExisting: false };
13
+ }
14
+ if (answer === '2' || answer === 'skip') {
15
+ return { overwrite: false, skipExisting: true };
16
+ }
17
+ return undefined;
18
+ }
19
+ finally {
20
+ readline.close();
21
+ }
22
+ };
@@ -0,0 +1,7 @@
1
+ export * from './conflict-strategy.js';
2
+ export * from './prompt.js';
3
+ export * from './provider.js';
4
+ export * from './preset.js';
5
+ export * from './resolve-option.js';
6
+ export * from './scope.js';
7
+ export type * from './types.js';
@@ -0,0 +1,6 @@
1
+ export * from './conflict-strategy.js';
2
+ export * from './prompt.js';
3
+ export * from './provider.js';
4
+ export * from './preset.js';
5
+ export * from './resolve-option.js';
6
+ export * from './scope.js';
@@ -0,0 +1,4 @@
1
+ import { presets as appPreset } from '../preset/index.js';
2
+ import type { PromptOutput, PromptQuestion } from './types.js';
3
+ export type PresetName = keyof typeof appPreset;
4
+ export declare const preset: (question: PromptQuestion, output: PromptOutput) => Promise<PresetName>;
@@ -0,0 +1,11 @@
1
+ import { presets as appPreset } from '../preset/index.js';
2
+ import { prompt } from './prompt.js';
3
+ import { resolveOption } from './resolve-option.js';
4
+ export const preset = async (question, output) => {
5
+ const defaultPreset = 'base';
6
+ const presetNames = Object.keys(appPreset);
7
+ output.write('\nProject preset:\n\n');
8
+ presetNames.forEach((presetName, index) => output.write(` ${index + 1}. ${appPreset[presetName].name} - ${appPreset[presetName].description}\n`));
9
+ const presetValue = await prompt(question, '\nPreset number or name', defaultPreset);
10
+ return resolveOption(presetValue, presetNames, defaultPreset);
11
+ };
@@ -0,0 +1,2 @@
1
+ import type { Prompt } from '../plan/types.js';
2
+ export declare const prompt: Prompt;
@@ -0,0 +1,4 @@
1
+ export const prompt = async (question, label, defaultValue) => {
2
+ const answer = (await question(`${label} (${defaultValue}): `)).trim();
3
+ return answer || defaultValue;
4
+ };
@@ -0,0 +1,2 @@
1
+ import type { PromptOutput, PromptQuestion } from './types.js';
2
+ export declare const provider: <OptionName extends string>(question: PromptQuestion, output: PromptOutput, label: string, options: Partial<Record<OptionName, unknown>>) => Promise<OptionName | undefined>;
@@ -0,0 +1,13 @@
1
+ import { prompt } from './prompt.js';
2
+ import { resolveOption } from './resolve-option.js';
3
+ export const provider = async (question, output, label, options) => {
4
+ const optionNames = Object.keys(options);
5
+ const defaultOption = optionNames[0];
6
+ if (defaultOption === undefined) {
7
+ return undefined;
8
+ }
9
+ output.write(`\n${label}:\n\n`);
10
+ optionNames.forEach((optionName, index) => output.write(` ${index + 1}. ${optionName}\n`));
11
+ const optionValue = await prompt(question, `\n${label} number or name`, defaultOption);
12
+ return resolveOption(optionValue, optionNames);
13
+ };
@@ -0,0 +1,6 @@
1
+ type ResolveOption = {
2
+ <OptionName extends string>(value: string, optionNames: readonly OptionName[], fallback: OptionName): OptionName;
3
+ <OptionName extends string>(value: string, optionNames: readonly OptionName[]): OptionName | undefined;
4
+ };
5
+ export declare const resolveOption: ResolveOption;
6
+ export {};
@@ -0,0 +1,8 @@
1
+ export const resolveOption = (value, optionNames, fallback) => {
2
+ const normalizedValue = value.trim();
3
+ const numericValue = Number.parseInt(normalizedValue, 10);
4
+ if (Number.isInteger(numericValue)) {
5
+ return optionNames[numericValue - 1] ?? fallback;
6
+ }
7
+ return optionNames.find((optionName) => optionName === normalizedValue) ?? fallback;
8
+ };
@@ -0,0 +1,2 @@
1
+ import type { PromptQuestion } from './types.js';
2
+ export declare const scope: (question: PromptQuestion, preset: string, name: string) => Promise<string | undefined>;
@@ -0,0 +1,2 @@
1
+ import { prompt } from './prompt.js';
2
+ export const scope = async (question, preset, name) => preset === 'base' ? undefined : prompt(question, 'Package scope', `@${name}`);
@@ -0,0 +1,4 @@
1
+ export type PromptQuestion = (query: string) => Promise<string>;
2
+ export type PromptOutput = {
3
+ write: (chunk: string) => unknown;
4
+ };
@@ -0,0 +1,2 @@
1
+ import type { Command } from './types.js';
2
+ export declare const dist: Command;
@@ -187,7 +187,7 @@ const copyRootFile = async (fileName) => {
187
187
  await copyFile(fileName, path.join(DIST_DIR, fileName));
188
188
  }
189
189
  };
190
- const publishRootPackageJson = async () => {
190
+ const distRootPackageJson = async () => {
191
191
  const packageJson = await readJson(PACKAGE_JSON_FILE);
192
192
  delete packageJson.agents;
193
193
  delete packageJson.dependencies;
@@ -196,10 +196,10 @@ const publishRootPackageJson = async () => {
196
196
  delete packageJson.devDependencies;
197
197
  await writeJson(path.join(DIST_DIR, PACKAGE_JSON_FILE), packageJson);
198
198
  };
199
- const publishRoot = async () => {
199
+ const distRoot = async () => {
200
200
  await copyRootFile(README_FILE);
201
201
  await copyRootFile(LICENSE_FILE);
202
- await publishRootPackageJson();
202
+ await distRootPackageJson();
203
203
  };
204
204
  const syncPackageRuntimeMetadata = (packageJson, rootPackageJson) => {
205
205
  if (packageJson.name !== 'vyriy') {
@@ -208,7 +208,7 @@ const syncPackageRuntimeMetadata = (packageJson, rootPackageJson) => {
208
208
  packageJson.packageManager = rootPackageJson.packageManager;
209
209
  packageJson.engines = rootPackageJson.engines;
210
210
  };
211
- const publishPackage = async (packageJsonPath, rootPackageJson) => {
211
+ const distPackage = async (packageJsonPath, rootPackageJson) => {
212
212
  const packageDirectory = path.dirname(packageJsonPath);
213
213
  const packageJson = await readJson(packageJsonPath);
214
214
  await removeEmptyJavaScriptFiles(packageDirectory);
@@ -250,12 +250,12 @@ const publishPackage = async (packageJsonPath, rootPackageJson) => {
250
250
  await makePackageBinsExecutable(packageDirectory, packageJson);
251
251
  await writeJson(packageJsonPath, packageJson);
252
252
  };
253
- export const runPublishCommand = async ({ cwd = process.cwd() } = {}) => {
253
+ export const dist = async () => {
254
254
  const previousCwd = process.cwd();
255
255
  try {
256
- process.chdir(cwd);
256
+ process.chdir(process.cwd());
257
257
  const rootPackageJson = await readJson(PACKAGE_JSON_FILE);
258
- await publishRoot();
258
+ await distRoot();
259
259
  const entries = await readdir(DIST_DIR, { withFileTypes: true });
260
260
  const packageJsonPaths = entries
261
261
  .filter((entry) => entry.isDirectory())
@@ -263,7 +263,7 @@ export const runPublishCommand = async ({ cwd = process.cwd() } = {}) => {
263
263
  .sort((left, right) => left.localeCompare(right));
264
264
  for (const packageJsonPath of packageJsonPaths) {
265
265
  if (await hasFile(packageJsonPath)) {
266
- await publishPackage(packageJsonPath, rootPackageJson);
266
+ await distPackage(packageJsonPath, rootPackageJson);
267
267
  }
268
268
  }
269
269
  return 0;
@@ -0,0 +1,3 @@
1
+ import { Command } from './types.js';
2
+ export declare const text = "Vyriy Project Master\n\nUsage:\n vyriy [name] Create a new Vyriy project\n vyriy . Initialize a new Vyriy project in the current directory\n vyriy --help, -h Show help\n vyriy --version, -v Show version\n vyriy --check-env, -c Check local environment\n vyriy --dist, -d Prepare dist package metadata without publishing to npm\n vyriy --dry-run Print checks and file plan without writing\n vyriy --overwrite Overwrite existing generated paths\n vyriy --skip-existing Leave existing generated paths untouched\n vyriy --no-install Create files without installing dependencies\n vyriy --no-verify Install dependencies without running checks\n\nExamples:\n vyriy app\n vyriy .\n vyriy -d";
3
+ export declare const help: Command;
@@ -0,0 +1,24 @@
1
+ export const text = `Vyriy Project Master
2
+
3
+ Usage:
4
+ vyriy [name] Create a new Vyriy project
5
+ vyriy . Initialize a new Vyriy project in the current directory
6
+ vyriy --help, -h Show help
7
+ vyriy --version, -v Show version
8
+ vyriy --check-env, -c Check local environment
9
+ vyriy --dist, -d Prepare dist package metadata without publishing to npm
10
+ vyriy --dry-run Print checks and file plan without writing
11
+ vyriy --overwrite Overwrite existing generated paths
12
+ vyriy --skip-existing Leave existing generated paths untouched
13
+ vyriy --no-install Create files without installing dependencies
14
+ vyriy --no-verify Install dependencies without running checks
15
+
16
+ Examples:
17
+ vyriy app
18
+ vyriy .
19
+ vyriy -d`;
20
+ export const help = async () => {
21
+ console.log(text);
22
+ await Promise.resolve();
23
+ return 0;
24
+ };
@@ -0,0 +1,5 @@
1
+ export * from './help.js';
2
+ export * from './version.js';
3
+ export * from './dist.js';
4
+ export * from './check-env.js';
5
+ export * from './create/index.js';
@@ -0,0 +1,5 @@
1
+ export * from './help.js';
2
+ export * from './version.js';
3
+ export * from './dist.js';
4
+ export * from './check-env.js';
5
+ export * from './create/index.js';
@@ -1,3 +1,21 @@
1
+ export type Command = () => Promise<number>;
2
+ export type Node = () => {
3
+ ok: boolean;
4
+ message: string;
5
+ };
6
+ export type Yarn = () => Promise<{
7
+ ok: boolean;
8
+ message: string;
9
+ }>;
10
+ export type CreateOptions = {
11
+ readonly directory: string;
12
+ readonly dryRun: boolean;
13
+ readonly overwrite: boolean;
14
+ readonly skipExisting: boolean;
15
+ readonly install: boolean;
16
+ readonly verify: boolean;
17
+ };
18
+ export type Create = (options: CreateOptions) => Promise<number>;
1
19
  export type ExportTarget = {
2
20
  readonly default: string;
3
21
  readonly import: string;
@@ -25,7 +43,3 @@ export type PackageJson = {
25
43
  workspaces?: unknown;
26
44
  [key: string]: unknown;
27
45
  };
28
- export type RunPublishCommandOptions = {
29
- readonly cwd?: string;
30
- };
31
- export type RunPublishCommand = (options?: RunPublishCommandOptions) => Promise<number>;
@@ -0,0 +1,2 @@
1
+ import { Command } from './types.js';
2
+ export declare const version: Command;
@@ -0,0 +1,6 @@
1
+ import packageJson from '../package.json' with { type: 'json' };
2
+ export const version = async () => {
3
+ console.log(packageJson.version);
4
+ await Promise.resolve();
5
+ return 0;
6
+ };