vyriy 0.5.1 → 0.5.3

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 (70) hide show
  1. package/README.md +23 -12
  2. package/args.js +40 -0
  3. package/bin/vyriy.js +1 -1
  4. package/cli.js +67 -0
  5. package/package.json +51 -6
  6. package/{cli/types.d.ts → types.d.ts} +7 -1
  7. package/cli/args.js +0 -29
  8. package/cli/cli.js +0 -28
  9. package/commands/check-env.d.ts +0 -2
  10. package/commands/check-env.js +0 -120
  11. package/commands/create/index.d.ts +0 -2
  12. package/commands/create/index.js +0 -135
  13. package/commands/create/plan/index.d.ts +0 -4
  14. package/commands/create/plan/index.js +0 -3
  15. package/commands/create/plan/plan.d.ts +0 -9
  16. package/commands/create/plan/plan.js +0 -34
  17. package/commands/create/plan/question.d.ts +0 -2
  18. package/commands/create/plan/question.js +0 -25
  19. package/commands/create/plan/types.d.ts +0 -14
  20. package/commands/create/preset/api.d.ts +0 -2
  21. package/commands/create/preset/api.js +0 -69
  22. package/commands/create/preset/base.d.ts +0 -2
  23. package/commands/create/preset/base.js +0 -195
  24. package/commands/create/preset/gql.d.ts +0 -2
  25. package/commands/create/preset/gql.js +0 -750
  26. package/commands/create/preset/index.d.ts +0 -47
  27. package/commands/create/preset/index.js +0 -56
  28. package/commands/create/preset/library.d.ts +0 -2
  29. package/commands/create/preset/library.js +0 -253
  30. package/commands/create/preset/mfe.d.ts +0 -2
  31. package/commands/create/preset/mfe.js +0 -333
  32. package/commands/create/preset/rest.d.ts +0 -2
  33. package/commands/create/preset/rest.js +0 -248
  34. package/commands/create/preset/shared.d.ts +0 -116
  35. package/commands/create/preset/shared.js +0 -245
  36. package/commands/create/preset/spa.d.ts +0 -2
  37. package/commands/create/preset/spa.js +0 -138
  38. package/commands/create/preset/ssg.d.ts +0 -2
  39. package/commands/create/preset/ssg.js +0 -177
  40. package/commands/create/preset/ssr.d.ts +0 -2
  41. package/commands/create/preset/ssr.js +0 -185
  42. package/commands/create/preset/types.d.ts +0 -15
  43. package/commands/create/prompt/conflict-strategy.d.ts +0 -5
  44. package/commands/create/prompt/conflict-strategy.js +0 -22
  45. package/commands/create/prompt/index.d.ts +0 -7
  46. package/commands/create/prompt/index.js +0 -6
  47. package/commands/create/prompt/preset.d.ts +0 -4
  48. package/commands/create/prompt/preset.js +0 -11
  49. package/commands/create/prompt/prompt.d.ts +0 -2
  50. package/commands/create/prompt/prompt.js +0 -4
  51. package/commands/create/prompt/provider.d.ts +0 -2
  52. package/commands/create/prompt/provider.js +0 -13
  53. package/commands/create/prompt/resolve-option.d.ts +0 -6
  54. package/commands/create/prompt/resolve-option.js +0 -8
  55. package/commands/create/prompt/scope.d.ts +0 -2
  56. package/commands/create/prompt/scope.js +0 -2
  57. package/commands/create/prompt/types.d.ts +0 -4
  58. package/commands/dist.d.ts +0 -2
  59. package/commands/dist.js +0 -287
  60. package/commands/help.d.ts +0 -3
  61. package/commands/help.js +0 -24
  62. package/commands/index.d.ts +0 -5
  63. package/commands/index.js +0 -5
  64. package/commands/types.d.ts +0 -44
  65. package/commands/version.d.ts +0 -2
  66. package/commands/version.js +0 -6
  67. /package/{cli/args.d.ts → args.d.ts} +0 -0
  68. /package/{cli/cli.d.ts → cli.d.ts} +0 -0
  69. /package/{cli/index.d.ts → index.d.ts} +0 -0
  70. /package/{cli/index.js → index.js} +0 -0
@@ -1,138 +0,0 @@
1
- import packageJson from '../../../package.json' with { type: 'json' };
2
- import { base } from './base.js';
3
- import { assetsDeclarationFile, baseToolingDeps, buildPackageJson, reactComponentFiles, reactDeps, reactWorkspaceScripts, stylelintConfigFile, stylelintDeps, webpackDeps, } from './shared.js';
4
- export const spa = {
5
- files: (options) => ({
6
- ...base.files(options),
7
- ...stylelintConfigFile(),
8
- ...assetsDeclarationFile(),
9
- ...reactComponentFiles(),
10
- 'package.json': buildPackageJson(options, [
11
- 'packages/*',
12
- 'workspaces/*',
13
- ], reactWorkspaceScripts('spa'), {
14
- ...baseToolingDeps(),
15
- ...webpackDeps(),
16
- ...reactDeps(),
17
- ...stylelintDeps(),
18
- '@vyriy/cn': `^${packageJson.version}`,
19
- '@vyriy/html': `^${packageJson.version}`,
20
- '@vyriy/browserslist-config': `^${packageJson.version}`,
21
- }),
22
- '.browserslistrc': `[development]
23
- extends @vyriy/browserslist-config
24
-
25
- [ssr]
26
- extends @vyriy/browserslist-config
27
-
28
- [production]
29
- extends @vyriy/browserslist-config
30
-
31
- [modern]
32
- extends @vyriy/browserslist-config
33
- `,
34
- 'workspaces/spa/bin/build.sh': `#!/usr/bin/env sh
35
-
36
- set -e
37
-
38
- scriptdir="$PWD/workspaces/spa";
39
-
40
- NODE_ENV=production npx webpack --config $scriptdir/webpack.config.ts
41
- `,
42
- 'workspaces/spa/bin/start.sh': `#!/usr/bin/env sh
43
-
44
- set -e
45
-
46
- scriptdir="$PWD/workspaces/spa";
47
-
48
- npx webpack serve --open --config $scriptdir/webpack.config.ts
49
- `,
50
- 'workspaces/spa/doc.mdx': `import { Meta, Markdown } from '@storybook/addon-docs/blocks';
51
- import ReadMe from './README.md?raw';
52
-
53
- <Meta title="Workspaces/SPA" />
54
-
55
- <Markdown>{ReadMe}</Markdown>
56
- `,
57
- 'workspaces/spa/README.md': `# ${options.name} SPA\n\n${options.description}\n`,
58
- 'workspaces/spa/webpack.config.ts': `import { csr, html } from '@vyriy/webpack-config';
59
- import { path } from '@vyriy/path';
60
-
61
- export default csr(
62
- '@w/spa',
63
- {
64
- path: path('dist', 'spa'),
65
- filename: 'index.js',
66
- },
67
- (config) => {
68
- return {
69
- ...config,
70
- plugins: [
71
- ...(config.plugins ?? []),
72
- html({
73
- title: '<title>SPA</title>',
74
- body: '<div id="root"></div>',
75
- }),
76
- ],
77
- };
78
- },
79
- );
80
- `,
81
- 'workspaces/spa/package.json': JSON.stringify({
82
- name: '@w/spa',
83
- type: 'module',
84
- private: true,
85
- }, null, 2) + '\n',
86
- 'workspaces/spa/index.tsx': `import { createRoot } from 'react-dom/client';
87
-
88
- import { Page } from '@p/components';
89
-
90
- import '@p/components/page/styles.scss';
91
-
92
- createRoot(document.getElementById('root')!).render(<Page content="Test content" />);
93
- `,
94
- 'workspaces/spa/index.test.tsx': `import type { ReactElement, ReactNode } from 'react';
95
- import { describe, expect, it, jest } from '@jest/globals';
96
-
97
- const renderMock = jest.fn<(children: ReactNode) => void>();
98
- const createRootMock = jest.fn<(container: Element | DocumentFragment) => { render: typeof renderMock }>(() => ({
99
- render: renderMock,
100
- }));
101
- const PageMock = jest.fn(({ content }: { content: string }) => <div>{content}</div>);
102
-
103
- jest.mock('react-dom/client', () => ({
104
- createRoot: createRootMock,
105
- }));
106
-
107
- jest.mock('@p/components', () => ({
108
- Page: PageMock,
109
- }));
110
-
111
- describe('workspaces/spa/index.tsx', () => {
112
- it('mounts the page component into the root element', async () => {
113
- document.body.innerHTML = '<div id="root"></div>';
114
- const rootElement = document.getElementById('root');
115
-
116
- if (!rootElement) {
117
- throw new Error('Expected root element to exist.');
118
- }
119
-
120
- await import('./index.js');
121
-
122
- expect(createRootMock).toHaveBeenCalledTimes(1);
123
- expect(createRootMock.mock.calls[0]?.[0]).toBe(rootElement);
124
- expect(renderMock).toHaveBeenCalledTimes(1);
125
-
126
- const renderedElement = renderMock.mock.calls[0]?.[0] as ReactElement<{ content: string }>;
127
-
128
- expect(renderedElement.type).toBe(PageMock);
129
- expect(renderedElement.props.content).toBe('Test content');
130
- });
131
- });
132
- `,
133
- }),
134
- ci: {
135
- ...base.ci,
136
- },
137
- deploy: {},
138
- };
@@ -1,2 +0,0 @@
1
- import { Preset } from './types.js';
2
- export declare const ssg: Preset;
@@ -1,177 +0,0 @@
1
- import packageJson from '../../../package.json' with { type: 'json' };
2
- import { base } from './base.js';
3
- import { assetsDeclarationFile, baseToolingDeps, buildPackageJson, reactComponentFiles, reactDeps, reactServiceFiles, reactWorkspaceScripts, stylelintConfigFile, stylelintDeps, webpackDeps, } from './shared.js';
4
- export const ssg = {
5
- files: (options) => ({
6
- ...base.files(options),
7
- ...stylelintConfigFile(),
8
- ...assetsDeclarationFile(),
9
- ...reactComponentFiles(),
10
- ...reactServiceFiles(),
11
- 'package.json': buildPackageJson(options, [
12
- 'packages/*',
13
- 'workspaces/*',
14
- ], reactWorkspaceScripts('ssg'), {
15
- ...baseToolingDeps(),
16
- ...webpackDeps(),
17
- '@vyriy/script': `^${packageJson.version}`,
18
- ...reactDeps(),
19
- ...stylelintDeps(),
20
- '@vyriy/cn': `^${packageJson.version}`,
21
- '@vyriy/html': `^${packageJson.version}`,
22
- sass: packageJson.peerDependencies.sass,
23
- }),
24
- 'workspaces/ssg/bin/build.sh': `#!/usr/bin/env sh
25
-
26
- set -e
27
-
28
- scriptdir="$PWD/workspaces/ssg";
29
- distdir="$PWD/dist/ssg";
30
-
31
- NODE_ENV=production npx webpack --config $scriptdir/webpack.config.ts
32
-
33
- yarn exec sass packages/components/page/styles.scss "$distdir/styles.css" --no-source-map --style=compressed
34
- cp $scriptdir/package.json "$distdir/package.json"
35
- npm pkg delete "type" --prefix "$distdir"
36
- npm pkg delete "private" --prefix "$distdir"
37
- `,
38
- 'workspaces/ssg/bin/start.sh': `#!/usr/bin/env sh
39
-
40
- set -e
41
-
42
- scriptdir="$PWD/workspaces/ssg";
43
- distdir="$PWD/dist/ssg";
44
-
45
- mkdir -p "$distdir"
46
- yarn exec sass packages/components/page/styles.scss "$distdir/styles.css" --no-source-map
47
-
48
- PROJECT_CWD="$distdir" NODE_ENV=production LOG_LEVEL=info "$PWD/node_modules/.bin/tsx" $scriptdir/index.tsx
49
- `,
50
- 'workspaces/ssg/doc.mdx': `import { Meta, Markdown } from '@storybook/addon-docs/blocks';
51
- import ReadMe from './README.md?raw';
52
-
53
- <Meta title="Workspaces/SSG" />
54
-
55
- <Markdown>{ReadMe}</Markdown>
56
- `,
57
- 'workspaces/ssg/README.md': `# ${options.name} SSG\n\n${options.description}\n`,
58
- 'workspaces/ssg/webpack.config.ts': `import { path } from '@vyriy/path';
59
- import { ssr, external } from '@vyriy/webpack-config';
60
-
61
- export default ssr(
62
- '@w/ssg',
63
- {
64
- path: path('dist', 'ssg'),
65
- filename: 'index.js',
66
- library: { type: 'commonjs2' },
67
- },
68
- (config) => ({
69
- ...config,
70
- externals: [external({ allowlist: [/^@p/, /^@w/, /^@vyriy/] })],
71
- }),
72
- );
73
- `,
74
- 'workspaces/ssg/package.json': JSON.stringify({
75
- name: '@w/ssg',
76
- type: 'module',
77
- private: true,
78
- }, null, 2) + '\n',
79
- 'workspaces/ssg/index.tsx': `import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
80
- import { renderToString } from 'react-dom/server';
81
-
82
- import { script } from '@vyriy/script';
83
- import { html, minify } from '@vyriy/html';
84
- import { path } from '@vyriy/path';
85
-
86
- import { cms } from '@p/services/cms';
87
- import { Page } from '@p/components';
88
-
89
- const dashboardStyles = readFileSync(path('styles.css'), 'utf8');
90
- const staticPath = path('static');
91
-
92
- void script(async () => {
93
- const content = await cms.getContent();
94
-
95
- mkdirSync(staticPath, { recursive: true });
96
-
97
- writeFileSync(
98
- path(staticPath, 'index.html'),
99
- minify(
100
- html({
101
- htmlAttributes: 'lang="en"',
102
- title: \`<title>\${content.title}</title>\`,
103
- meta: '<meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" />',
104
- style: \`<style>\${dashboardStyles.trim()}</style>\`,
105
- body: renderToString(<Page content={content.body} />),
106
- }),
107
- ),
108
- );
109
- });
110
- `,
111
- 'workspaces/ssg/index.test.tsx': `import { describe, expect, it, jest } from '@jest/globals';
112
-
113
- const getContentMock = jest.fn(() =>
114
- Promise.resolve({
115
- title: 'Sample Content',
116
- body: 'This is a sample content fetched from the CMS.',
117
- }),
118
- );
119
- let scriptPromise: Promise<void> | undefined;
120
- const scriptMock = jest.fn((handler: () => Promise<void>) => {
121
- scriptPromise = handler();
122
-
123
- return scriptPromise;
124
- });
125
- const nodeFs = jest.requireActual<typeof import('node:fs')>('node:fs');
126
- const mkdirSyncMock = jest.fn();
127
- const readFileSyncMock = jest.fn<(path: string | URL, encoding: 'utf8') => string>(
128
- () => '.content { display: block; }',
129
- );
130
- const writeFileSyncMock = jest.fn();
131
-
132
- jest.mock('node:fs', () => ({
133
- ...nodeFs,
134
- mkdirSync: mkdirSyncMock,
135
- readFileSync: readFileSyncMock,
136
- writeFileSync: writeFileSyncMock,
137
- }));
138
-
139
- jest.mock('@vyriy/script', () => ({
140
- script: scriptMock,
141
- }));
142
-
143
- jest.mock('@p/services/cms', () => ({
144
- cms: {
145
- getContent: getContentMock,
146
- },
147
- }));
148
-
149
- describe('workspaces/ssg/index.tsx', () => {
150
- it('generates a static index HTML file', async () => {
151
- await import('./index.js');
152
- await scriptPromise;
153
-
154
- expect(scriptMock).toHaveBeenCalledTimes(1);
155
- expect(readFileSyncMock).toHaveBeenCalledWith(expect.stringContaining('styles.css'), 'utf8');
156
- expect(getContentMock).toHaveBeenCalledTimes(1);
157
- expect(mkdirSyncMock).toHaveBeenCalledWith(expect.stringContaining('static'), {
158
- recursive: true,
159
- });
160
- expect(writeFileSyncMock).toHaveBeenCalledWith(
161
- expect.stringContaining('static/index.html'),
162
- expect.stringContaining('<title>Sample Content</title>'),
163
- );
164
-
165
- const generatedHtml = writeFileSyncMock.mock.calls[0]?.[1] as string;
166
-
167
- expect(generatedHtml).toContain('<style>.content { display: block; }</style>');
168
- expect(generatedHtml).toContain('This is a sample content fetched from the CMS.');
169
- });
170
- });
171
- `,
172
- }),
173
- ci: {
174
- ...base.ci,
175
- },
176
- deploy: {},
177
- };
@@ -1,2 +0,0 @@
1
- import { Preset } from './types.js';
2
- export declare const ssr: Preset;
@@ -1,185 +0,0 @@
1
- import packageJson from '../../../package.json' with { type: 'json' };
2
- import { base } from './base.js';
3
- import { assetsDeclarationFile, baseToolingDeps, buildPackageJson, reactComponentFiles, reactDeps, reactServiceFiles, reactWorkspaceScripts, serverDeps, stylelintConfigFile, stylelintDeps, webpackDeps, } from './shared.js';
4
- export const ssr = {
5
- files: (options) => ({
6
- ...base.files(options),
7
- ...stylelintConfigFile(),
8
- ...assetsDeclarationFile(),
9
- ...reactComponentFiles(),
10
- ...reactServiceFiles(),
11
- 'package.json': buildPackageJson(options, [
12
- 'packages/*',
13
- 'workspaces/*',
14
- ], reactWorkspaceScripts('api'), {
15
- ...baseToolingDeps(),
16
- ...webpackDeps(),
17
- ...serverDeps(),
18
- ...reactDeps(),
19
- ...stylelintDeps(),
20
- '@vyriy/cn': `^${packageJson.version}`,
21
- '@vyriy/html': `^${packageJson.version}`,
22
- sass: packageJson.peerDependencies.sass,
23
- }),
24
- 'workspaces/api/bin/build.sh': `#!/usr/bin/env sh
25
-
26
- set -e
27
-
28
- scriptdir="$PWD/workspaces/api";
29
- distdir="$PWD/dist/api";
30
-
31
- NODE_ENV=production npx webpack --config $scriptdir/webpack.config.ts
32
-
33
- yarn exec sass packages/components/page/styles.scss "$distdir/styles.css" --no-source-map --style=compressed
34
- cp $scriptdir/package.json "$distdir/package.json"
35
- npm pkg delete "type" --prefix "$distdir"
36
- npm pkg delete "private" --prefix "$distdir"
37
- `,
38
- 'workspaces/api/bin/start.sh': `#!/usr/bin/env sh
39
-
40
- set -e
41
-
42
- scriptdir="$PWD/workspaces/api";
43
- distdir="$PWD/dist/api";
44
-
45
- mkdir -p "$distdir"
46
- yarn exec sass packages/components/page/styles.scss "$distdir/styles.css" --no-source-map
47
-
48
- PROJECT_CWD="$distdir" NODE_ENV=production LOG_LEVEL=info "$PWD/node_modules/.bin/tsx" $scriptdir/index.tsx
49
- `,
50
- 'workspaces/api/doc.mdx': `import { Meta, Markdown } from '@storybook/addon-docs/blocks';
51
- import ReadMe from './README.md?raw';
52
-
53
- <Meta title="Workspaces/API" />
54
-
55
- <Markdown>{ReadMe}</Markdown>
56
- `,
57
- 'workspaces/api/README.md': `# ${options.name} API\n\n${options.description}\n`,
58
- 'workspaces/api/webpack.config.ts': `import { path } from '@vyriy/path';
59
- import { ssr, external } from '@vyriy/webpack-config';
60
-
61
- export default ssr(
62
- '@w/api',
63
- {
64
- path: path('dist', 'api'),
65
- filename: 'index.js',
66
- library: { type: 'commonjs2' },
67
- },
68
- (config) => ({
69
- ...config,
70
- externals: [external({ allowlist: [/^@p/, /^@w/, /^@vyriy/] })],
71
- }),
72
- );
73
- `,
74
- 'workspaces/api/package.json': JSON.stringify({
75
- name: '@w/api',
76
- type: 'module',
77
- private: true,
78
- }, null, 2) + '\n',
79
- 'workspaces/api/index.tsx': `import { readFileSync } from 'node:fs';
80
- import { renderToString } from 'react-dom/server';
81
-
82
- import { server } from '@vyriy/server';
83
- import { api } from '@vyriy/handler';
84
- import { html, minify } from '@vyriy/html';
85
- import { path } from '@vyriy/path';
86
-
87
- import { cms } from '@p/services/cms';
88
- import { Page } from '@p/components';
89
-
90
- const dashboardStyles = readFileSync(path('styles.css'), 'utf8');
91
-
92
- server(
93
- api(async () => {
94
- const content = await cms.getContent();
95
-
96
- return {
97
- statusCode: 200,
98
- headers: {
99
- 'content-type': 'text/html; charset=utf-8',
100
- },
101
- body: minify(
102
- html({
103
- htmlAttributes: 'lang="en"',
104
- title: \`<title>\${content.title}</title>\`,
105
- meta: '<meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" />',
106
- style: \`<style>\${dashboardStyles.trim()}</style>\`,
107
- body: renderToString(<Page content={content.body} />),
108
- }),
109
- ),
110
- };
111
- }),
112
- );
113
- `,
114
- 'workspaces/api/index.test.tsx': `import { describe, expect, it, jest } from '@jest/globals';
115
-
116
- const apiMock = jest.fn((handler) => ({
117
- handler,
118
- }));
119
- const getContentMock = jest.fn(() =>
120
- Promise.resolve({
121
- title: 'Sample Content',
122
- body: 'This is a sample content fetched from the CMS.',
123
- }),
124
- );
125
- const nodeFs = jest.requireActual<typeof import('node:fs')>('node:fs');
126
- const readFileSyncMock = jest.fn<(path: string | URL, encoding: 'utf8') => string>(
127
- () => '.content { display: block; }',
128
- );
129
- const serverMock = jest.fn();
130
-
131
- jest.mock('node:fs', () => ({
132
- ...nodeFs,
133
- readFileSync: readFileSyncMock,
134
- }));
135
-
136
- jest.mock('@vyriy/handler', () => ({
137
- api: apiMock,
138
- }));
139
-
140
- jest.mock('@vyriy/server', () => ({
141
- server: serverMock,
142
- }));
143
-
144
- jest.mock('@p/services/cms', () => ({
145
- cms: {
146
- getContent: getContentMock,
147
- },
148
- }));
149
-
150
- describe('workspaces/api/index.tsx', () => {
151
- it('starts the server with a handler that returns rendered page HTML', async () => {
152
- await import('./index.js');
153
-
154
- expect(apiMock).toHaveBeenCalledTimes(1);
155
- expect(serverMock).toHaveBeenCalledTimes(1);
156
- expect(serverMock).toHaveBeenCalledWith(apiMock.mock.results[0]?.value);
157
-
158
- const handler = apiMock.mock.calls[0]?.[0] as () => Promise<{
159
- statusCode: number;
160
- headers: Record<string, string>;
161
- body: string;
162
- }>;
163
-
164
- const response = await handler();
165
-
166
- expect(response).toEqual({
167
- statusCode: 200,
168
- headers: {
169
- 'content-type': 'text/html; charset=utf-8',
170
- },
171
- body: expect.stringContaining('<title>Sample Content</title>'),
172
- });
173
- expect(response.body).toContain('<style>.content { display: block; }</style>');
174
- expect(response.body).toContain('This is a sample content fetched from the CMS.');
175
- expect(readFileSyncMock).toHaveBeenCalledWith(expect.stringContaining('styles.css'), 'utf8');
176
- expect(getContentMock).toHaveBeenCalledTimes(1);
177
- });
178
- });
179
- `,
180
- }),
181
- ci: {
182
- ...base.ci,
183
- },
184
- deploy: {},
185
- };
@@ -1,15 +0,0 @@
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
- }>>;
@@ -1,5 +0,0 @@
1
- export type ConflictStrategy = {
2
- readonly overwrite: boolean;
3
- readonly skipExisting: boolean;
4
- };
5
- export declare const conflictStrategy: () => Promise<ConflictStrategy | undefined>;
@@ -1,22 +0,0 @@
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
- };
@@ -1,7 +0,0 @@
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';
@@ -1,6 +0,0 @@
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';
@@ -1,4 +0,0 @@
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>;
@@ -1,11 +0,0 @@
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
- };
@@ -1,2 +0,0 @@
1
- import type { Prompt } from '../plan/types.js';
2
- export declare const prompt: Prompt;
@@ -1,4 +0,0 @@
1
- export const prompt = async (question, label, defaultValue) => {
2
- const answer = (await question(`${label} (${defaultValue}): `)).trim();
3
- return answer || defaultValue;
4
- };
@@ -1,2 +0,0 @@
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>;
@@ -1,13 +0,0 @@
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
- };
@@ -1,6 +0,0 @@
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 {};
@@ -1,8 +0,0 @@
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
- };
@@ -1,2 +0,0 @@
1
- import type { PromptQuestion } from './types.js';
2
- export declare const scope: (question: PromptQuestion, preset: string, name: string) => Promise<string | undefined>;
@@ -1,2 +0,0 @@
1
- import { prompt } from './prompt.js';
2
- export const scope = async (question, preset, name) => preset === 'library' ? prompt(question, 'Package scope', `@${name}`) : undefined;
@@ -1,4 +0,0 @@
1
- export type PromptQuestion = (query: string) => Promise<string>;
2
- export type PromptOutput = {
3
- write: (chunk: string) => unknown;
4
- };
@@ -1,2 +0,0 @@
1
- import type { Command } from './types.js';
2
- export declare const dist: Command;