@enfyra/create 0.1.2 → 0.1.4
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.
|
@@ -18,9 +18,8 @@ function detectPackageManagers() {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
function getWorkspaceRunCommand(packageManager, workspace, script) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return `npm run ${script} -w ${workspace}`;
|
|
21
|
+
const runCommand = packageManager === 'yarn' ? `yarn ${script}` : `${packageManager} run ${script}`;
|
|
22
|
+
return `(cd ${workspace} && ${runCommand})`;
|
|
24
23
|
}
|
|
25
24
|
|
|
26
25
|
function getPackageRunCommand(packageManager, script) {
|
|
@@ -8,6 +8,7 @@ const { generateEnvFiles } = require('./env-builder');
|
|
|
8
8
|
const {
|
|
9
9
|
getInstallCommand,
|
|
10
10
|
getPackageExecCommand,
|
|
11
|
+
getPackageRunCommand,
|
|
11
12
|
getWorkspaceRunCommand,
|
|
12
13
|
} = require('./package-managers');
|
|
13
14
|
|
|
@@ -66,6 +67,8 @@ async function updateWorkspacePackageJson(projectPath, config) {
|
|
|
66
67
|
const packageName = toPackageName(config.projectName);
|
|
67
68
|
const packageManager = config.packageManager;
|
|
68
69
|
const resolutions = await collectTemplateResolutions(projectPath);
|
|
70
|
+
const serverReadyTarget = `tcp:localhost:${config.serverPort}`;
|
|
71
|
+
const waitForServerCommand = getPackageExecCommand(packageManager, 'wait-on', [serverReadyTarget]);
|
|
69
72
|
const packageJson = {
|
|
70
73
|
name: packageName,
|
|
71
74
|
version: '0.1.0',
|
|
@@ -75,13 +78,17 @@ async function updateWorkspacePackageJson(projectPath, config) {
|
|
|
75
78
|
'server',
|
|
76
79
|
],
|
|
77
80
|
scripts: {
|
|
78
|
-
dev: `concurrently -k -n server,app -c cyan,green "${getWorkspaceRunCommand(packageManager, 'server', 'dev')}" "${
|
|
81
|
+
dev: `concurrently -k -n server,app -c cyan,green "${getWorkspaceRunCommand(packageManager, 'server', 'dev')}" "${waitForServerCommand} && ${getWorkspaceRunCommand(packageManager, 'app', 'dev')}"`,
|
|
79
82
|
'dev:app': getWorkspaceRunCommand(packageManager, 'app', 'dev'),
|
|
80
83
|
'dev:server': getWorkspaceRunCommand(packageManager, 'server', 'dev'),
|
|
81
84
|
build: `${getWorkspaceRunCommand(packageManager, 'server', 'build')} && ${getWorkspaceRunCommand(packageManager, 'app', 'build')}`,
|
|
82
85
|
'build:app': getWorkspaceRunCommand(packageManager, 'app', 'build'),
|
|
83
86
|
'build:server': getWorkspaceRunCommand(packageManager, 'server', 'build'),
|
|
84
|
-
start: getWorkspaceRunCommand(packageManager, 'server', 'start'),
|
|
87
|
+
start: `concurrently -k -n server,app -c cyan,green "${getWorkspaceRunCommand(packageManager, 'server', 'start')}" "${waitForServerCommand} && ${getWorkspaceRunCommand(packageManager, 'app', 'start')}"`,
|
|
88
|
+
'start:app': getWorkspaceRunCommand(packageManager, 'app', 'start'),
|
|
89
|
+
'start:server': getWorkspaceRunCommand(packageManager, 'server', 'start'),
|
|
90
|
+
serve: getPackageRunCommand(packageManager, 'start'),
|
|
91
|
+
'preview:app': getWorkspaceRunCommand(packageManager, 'app', 'preview'),
|
|
85
92
|
},
|
|
86
93
|
devDependencies: {
|
|
87
94
|
concurrently: '^9.2.1',
|
|
@@ -106,6 +113,17 @@ async function updateWorkspacePackageJson(projectPath, config) {
|
|
|
106
113
|
}
|
|
107
114
|
|
|
108
115
|
async function writePackageManagerConfig(projectPath, config) {
|
|
116
|
+
if (config.packageManager === 'npm') {
|
|
117
|
+
await fs.writeFile(
|
|
118
|
+
path.join(projectPath, '.npmrc'),
|
|
119
|
+
[
|
|
120
|
+
'install-strategy=nested',
|
|
121
|
+
'',
|
|
122
|
+
].join('\n'),
|
|
123
|
+
);
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
|
|
109
127
|
if (config.packageManager !== 'yarn') return;
|
|
110
128
|
|
|
111
129
|
await fs.writeFile(
|
|
@@ -118,6 +136,8 @@ async function writePackageManagerConfig(projectPath, config) {
|
|
|
118
136
|
'',
|
|
119
137
|
'nodeLinker: node-modules',
|
|
120
138
|
'',
|
|
139
|
+
'nmHoistingLimits: workspaces',
|
|
140
|
+
'',
|
|
121
141
|
'npmMinimalAgeGate: 0',
|
|
122
142
|
'',
|
|
123
143
|
].join('\n'),
|