vyriy 0.4.11 → 0.5.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/commands/create/index.js +24 -21
- package/commands/create/plan/plan.d.ts +1 -1
- package/commands/create/preset/api.js +9 -106
- package/commands/create/preset/index.d.ts +5 -0
- package/commands/create/preset/index.js +6 -0
- package/commands/create/preset/library.js +2 -1
- package/commands/create/preset/mfe.js +325 -8
- package/commands/create/preset/rest.js +11 -107
- package/commands/create/preset/shared.d.ts +116 -0
- package/commands/create/preset/shared.js +245 -0
- package/commands/create/preset/spa.js +16 -126
- package/commands/create/preset/ssg.js +18 -155
- package/commands/create/preset/ssr.js +18 -156
- package/package.json +22 -2
package/commands/create/index.js
CHANGED
|
@@ -21,7 +21,7 @@ const mergeFiles = (planOption) => {
|
|
|
21
21
|
...getProviderFiles(preset.deploy, planOption.deploy),
|
|
22
22
|
};
|
|
23
23
|
};
|
|
24
|
-
const getSortedFileNames = (files) => Object.keys(files).sort();
|
|
24
|
+
const getSortedFileNames = (files) => Object.keys(files).sort((a, b) => a.localeCompare(b));
|
|
25
25
|
const logFilePlan = (target, files) => {
|
|
26
26
|
console.log(`\nFile plan (${target}):`);
|
|
27
27
|
console.log(' ', getSortedFileNames(files).join('\n '));
|
|
@@ -69,6 +69,28 @@ const verifyProject = async (target) => {
|
|
|
69
69
|
await exec(`yarn --cwd ${target} check`);
|
|
70
70
|
}
|
|
71
71
|
};
|
|
72
|
+
const installAndVerify = async (target, install, verify) => {
|
|
73
|
+
if (install) {
|
|
74
|
+
console.log('Installing dependencies...');
|
|
75
|
+
await exec(`yarn --cwd ${target} set version berry`);
|
|
76
|
+
await exec(`yarn --cwd ${target} install`);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
console.log('Installing dependencies... SKIPPED');
|
|
80
|
+
console.log('Running checks... SKIPPED');
|
|
81
|
+
console.log('\nProject files were created.');
|
|
82
|
+
return 0;
|
|
83
|
+
}
|
|
84
|
+
if (verify) {
|
|
85
|
+
await verifyProject(target);
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
console.log('Running checks... SKIPPED');
|
|
89
|
+
console.log('\nProject files were created.');
|
|
90
|
+
return 0;
|
|
91
|
+
}
|
|
92
|
+
return 0;
|
|
93
|
+
};
|
|
72
94
|
export const create = async (options) => {
|
|
73
95
|
const { directory, dryRun, overwrite, skipExisting, install, verify } = options;
|
|
74
96
|
const checkEnvCode = await checkEnv();
|
|
@@ -107,26 +129,7 @@ export const create = async (options) => {
|
|
|
107
129
|
return 1;
|
|
108
130
|
}
|
|
109
131
|
writeFiles(target, files, conflictStrategy.overwrite);
|
|
110
|
-
|
|
111
|
-
console.log('Installing dependencies...');
|
|
112
|
-
await exec(`yarn --cwd ${target} set version berry`);
|
|
113
|
-
await exec(`yarn --cwd ${target} install`);
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
console.log('Installing dependencies... SKIPPED');
|
|
117
|
-
console.log('Running checks... SKIPPED');
|
|
118
|
-
console.log('\nProject files were created.');
|
|
119
|
-
return 0;
|
|
120
|
-
}
|
|
121
|
-
if (verify) {
|
|
122
|
-
await verifyProject(target);
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
console.log('Running checks... SKIPPED');
|
|
126
|
-
console.log('\nProject files were created.');
|
|
127
|
-
return 0;
|
|
128
|
-
}
|
|
129
|
-
return 0;
|
|
132
|
+
return installAndVerify(target, install, verify);
|
|
130
133
|
}
|
|
131
134
|
return 1;
|
|
132
135
|
};
|
|
@@ -2,7 +2,7 @@ export declare const plan: (dirName: string, appPath: string) => Promise<{
|
|
|
2
2
|
name: string;
|
|
3
3
|
description: string;
|
|
4
4
|
target: string;
|
|
5
|
-
preset: "ssr" | "base" | "rest" | "api" | "library" | "gql" | "ssg" | "spa";
|
|
5
|
+
preset: "ssr" | "base" | "rest" | "api" | "library" | "gql" | "ssg" | "spa" | "mfe";
|
|
6
6
|
scope: string | undefined;
|
|
7
7
|
ci: import("../preset/types.js").CiProvider | undefined;
|
|
8
8
|
deploy: import("../preset/types.js").DeployProvider | undefined;
|
|
@@ -1,113 +1,16 @@
|
|
|
1
|
-
import packageJson from '../../../package.json' with { type: 'json' };
|
|
2
1
|
import { base } from './base.js';
|
|
2
|
+
import { apiWorkspaceBaseFiles, baseToolingDeps, buildPackageJson, serverDeps, webpackDeps, workspaceScripts, } from './shared.js';
|
|
3
3
|
export const api = {
|
|
4
4
|
files: (options) => ({
|
|
5
5
|
...base.files(options),
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
engines: {
|
|
15
|
-
node: packageJson.engines.node,
|
|
16
|
-
},
|
|
17
|
-
workspaces: [
|
|
18
|
-
'workspaces/*',
|
|
19
|
-
],
|
|
20
|
-
scripts: {
|
|
21
|
-
storybook: 'cross-env STORYBOOK_DISABLE_TELEMETRY=1 storybook dev -p 6006 --disable-telemetry',
|
|
22
|
-
check: 'run-s lint build test',
|
|
23
|
-
fix: "run-s 'fix:*'",
|
|
24
|
-
start: "run-p 'start:*'",
|
|
25
|
-
lint: "run-s 'lint:*'",
|
|
26
|
-
build: "run-s 'build:*'",
|
|
27
|
-
test: "run-s 'test:*'",
|
|
28
|
-
'fix:prettier': 'prettier . --write',
|
|
29
|
-
'fix:eslint': 'eslint . --fix',
|
|
30
|
-
'start:api': 'sh workspaces/api/bin/start.sh',
|
|
31
|
-
'lint:ts': 'tsc',
|
|
32
|
-
'lint:prettier': 'prettier . --check',
|
|
33
|
-
'lint:eslint': 'eslint .',
|
|
34
|
-
'build:api': 'rimraf dist && sh workspaces/api/bin/build.sh',
|
|
35
|
-
'build:storybook': 'cross-env STORYBOOK_DISABLE_TELEMETRY=1 storybook build --quiet --disable-telemetry',
|
|
36
|
-
'test:jest': 'jest',
|
|
37
|
-
postinstall: 'husky',
|
|
38
|
-
},
|
|
39
|
-
dependencies: {
|
|
40
|
-
'@vyriy/typescript-config': `^${packageJson.version}`,
|
|
41
|
-
typescript: packageJson.peerDependencies.typescript,
|
|
42
|
-
'@vyriy/prettier-config': `^${packageJson.version}`,
|
|
43
|
-
prettier: packageJson.peerDependencies.prettier,
|
|
44
|
-
'@vyriy/eslint-config': `^${packageJson.version}`,
|
|
45
|
-
eslint: packageJson.peerDependencies.eslint,
|
|
46
|
-
'@vyriy/jest-config': `^${packageJson.version}`,
|
|
47
|
-
jest: packageJson.peerDependencies.jest,
|
|
48
|
-
'@vyriy/storybook-config': `^${packageJson.version}`,
|
|
49
|
-
storybook: packageJson.peerDependencies.storybook,
|
|
50
|
-
'@vyriy/path': `^${packageJson.version}`,
|
|
51
|
-
husky: packageJson.peerDependencies.husky,
|
|
52
|
-
'npm-run-all2': packageJson.peerDependencies['npm-run-all2'],
|
|
53
|
-
'cross-env': packageJson.peerDependencies['cross-env'],
|
|
54
|
-
rimraf: packageJson.peerDependencies.rimraf,
|
|
55
|
-
'@vyriy/webpack-config': `^${packageJson.version}`,
|
|
56
|
-
'@vyriy/handler': `^${packageJson.version}`,
|
|
57
|
-
'@vyriy/server': `^${packageJson.version}`,
|
|
58
|
-
tsx: packageJson.peerDependencies.tsx,
|
|
59
|
-
'webpack-cli': packageJson.peerDependencies['webpack-cli'],
|
|
60
|
-
},
|
|
61
|
-
}, null, 2) + '\n',
|
|
62
|
-
'workspaces/api/bin/build.sh': `#!/usr/bin/env sh
|
|
63
|
-
|
|
64
|
-
set -e
|
|
65
|
-
|
|
66
|
-
scriptdir="$PWD/workspaces/api";
|
|
67
|
-
|
|
68
|
-
NODE_ENV=production npx webpack --config $scriptdir/webpack.config.ts
|
|
69
|
-
|
|
70
|
-
cp $scriptdir/package.json dist/api/package.json
|
|
71
|
-
npm pkg delete "type" --prefix dist/api
|
|
72
|
-
npm pkg delete "private" --prefix dist/api
|
|
73
|
-
`,
|
|
74
|
-
'workspaces/api/bin/start.sh': `#!/usr/bin/env sh
|
|
75
|
-
|
|
76
|
-
set -e
|
|
77
|
-
|
|
78
|
-
scriptdir="$PWD/workspaces/api";
|
|
79
|
-
|
|
80
|
-
NODE_ENV=production LOG_LEVEL=info tsx $scriptdir/index.ts
|
|
81
|
-
`,
|
|
82
|
-
'workspaces/api/doc.mdx': `import { Meta, Markdown } from '@storybook/addon-docs/blocks';
|
|
83
|
-
import ReadMe from './README.md?raw';
|
|
84
|
-
|
|
85
|
-
<Meta title="Workspaces/API" />
|
|
86
|
-
|
|
87
|
-
<Markdown>{ReadMe}</Markdown>
|
|
88
|
-
`,
|
|
89
|
-
'workspaces/api/README.md': `# ${options.name} API\n\n${options.description}\n`,
|
|
90
|
-
'workspaces/api/webpack.config.ts': `import { path } from '@vyriy/path';
|
|
91
|
-
import { ssr, external } from '@vyriy/webpack-config';
|
|
92
|
-
|
|
93
|
-
export default ssr(
|
|
94
|
-
'@w/api',
|
|
95
|
-
{
|
|
96
|
-
path: path('dist', 'api'),
|
|
97
|
-
filename: 'index.js',
|
|
98
|
-
library: { type: 'commonjs2' },
|
|
99
|
-
},
|
|
100
|
-
(config) => ({
|
|
101
|
-
...config,
|
|
102
|
-
externals: [external({ allowlist: [/^@p/, /^@w/, /^@vyriy/] })],
|
|
103
|
-
}),
|
|
104
|
-
);
|
|
105
|
-
`,
|
|
106
|
-
'workspaces/api/package.json': JSON.stringify({
|
|
107
|
-
name: '@w/api',
|
|
108
|
-
type: 'module',
|
|
109
|
-
private: true,
|
|
110
|
-
}, null, 2) + '\n',
|
|
6
|
+
...apiWorkspaceBaseFiles(options.name, options.description),
|
|
7
|
+
'package.json': buildPackageJson(options, [
|
|
8
|
+
'workspaces/*',
|
|
9
|
+
], workspaceScripts('api'), {
|
|
10
|
+
...baseToolingDeps(),
|
|
11
|
+
...webpackDeps(),
|
|
12
|
+
...serverDeps(),
|
|
13
|
+
}),
|
|
111
14
|
'workspaces/api/index.ts': `import { server } from '@vyriy/server';
|
|
112
15
|
import { api } from '@vyriy/handler';
|
|
113
16
|
|
|
@@ -6,6 +6,7 @@ import { ssg } from './ssg.js';
|
|
|
6
6
|
import { spa } from './spa.js';
|
|
7
7
|
import { rest } from './rest.js';
|
|
8
8
|
import { gql } from './gql.js';
|
|
9
|
+
import { mfe } from './mfe.js';
|
|
9
10
|
export const presets = {
|
|
10
11
|
base: {
|
|
11
12
|
name: 'Base',
|
|
@@ -47,4 +48,9 @@ export const presets = {
|
|
|
47
48
|
description: 'Preset for GraphQL API',
|
|
48
49
|
preset: gql,
|
|
49
50
|
},
|
|
51
|
+
mfe: {
|
|
52
|
+
name: 'MFE',
|
|
53
|
+
description: 'Preset for Micro Frontend',
|
|
54
|
+
preset: mfe,
|
|
55
|
+
},
|
|
50
56
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import packageJson from '../../../package.json' with { type: 'json' };
|
|
2
2
|
import { base } from './base.js';
|
|
3
|
+
import { stylelintConfigFile } from './shared.js';
|
|
3
4
|
export const library = {
|
|
4
5
|
files: (options) => {
|
|
5
6
|
const packageScope = options.scope ?? `@${options.name}`;
|
|
@@ -90,7 +91,7 @@ export const library = {
|
|
|
90
91
|
allowImportingTsExtensions: false,
|
|
91
92
|
},
|
|
92
93
|
}, null, 2) + '\n',
|
|
93
|
-
|
|
94
|
+
...stylelintConfigFile(),
|
|
94
95
|
[`packages/${options.name}/package.json`]: JSON.stringify({
|
|
95
96
|
name: packageName,
|
|
96
97
|
version: '0.0.0',
|