@quilted/create 0.1.83 → 0.1.85
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/CHANGELOG.md +14 -0
- package/build/cjs/app.cjs +7 -1
- package/build/cjs/package.cjs +50 -93
- package/build/cjs/shared/prompts.cjs +1 -1
- package/build/cjs/shared.cjs +5 -0
- package/build/esm/app.mjs +7 -1
- package/build/esm/package.mjs +51 -94
- package/build/esm/shared/prompts.mjs +1 -1
- package/build/esm/shared.mjs +5 -0
- package/build/esnext/app.esnext +7 -1
- package/build/esnext/package.esnext +51 -94
- package/build/esnext/shared/prompts.esnext +1 -1
- package/build/esnext/shared.esnext +5 -0
- package/build/tsconfig.tsbuildinfo +1 -1
- package/build/typescript/app.d.ts.map +1 -1
- package/build/typescript/package.d.ts.map +1 -1
- package/build/typescript/shared.d.ts +2 -1
- package/build/typescript/shared.d.ts.map +1 -1
- package/package.json +1 -1
- package/source/app.ts +13 -1
- package/source/package.ts +89 -157
- package/source/shared/prompts.ts +1 -1
- package/source/shared.ts +10 -0
- package/templates/app-graphql/tests/graphql.ts +1 -0
- package/templates/github/_github/workflows/ci.yml +4 -4
- package/templates/package-simple/README.md +1 -0
- package/templates/package-simple/package.json +51 -0
- package/templates/package-simple/rollup.config.js +3 -0
- package/templates/package-simple/source/index.test.ts +9 -0
- package/templates/package-simple/source/index.ts +3 -0
- package/templates/package-simple/tsconfig.json +10 -0
- package/templates/workspace-simple/_gitignore +13 -0
- package/templates/workspace-simple/_nvmrc +1 -0
- package/templates/workspace-simple/_prettierignore +8 -0
- package/templates/workspace-simple/package.json +26 -0
- package/templates/workspace-simple/tsconfig.json +8 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @quilted/create
|
|
2
2
|
|
|
3
|
+
## 0.1.85
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`25413301`](https://github.com/lemonmade/quilt/commit/25413301513cdee72156a70ff14095e145cafb91) Thanks [@lemonmade](https://github.com/lemonmade)! - Add simpler package template
|
|
8
|
+
|
|
9
|
+
## 0.1.84
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`47b00612`](https://github.com/lemonmade/quilt/commit/47b006120622504c132559d7c6c66352138c288d) Thanks [@lemonmade](https://github.com/lemonmade)! - Fix `fetch()` polyfill for GraphQL template tests
|
|
14
|
+
|
|
15
|
+
- [`c51c24c3`](https://github.com/lemonmade/quilt/commit/c51c24c37617a24a68ec0ad8f5880094213f4371) Thanks [@lemonmade](https://github.com/lemonmade)! - Fix template creation with nested gitignores
|
|
16
|
+
|
|
3
17
|
## 0.1.83
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/build/cjs/app.cjs
CHANGED
|
@@ -155,11 +155,14 @@ async function createApp() {
|
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
157
|
await appTemplate.copy(appDirectory, file => {
|
|
158
|
-
// If we are in a monorepo, we
|
|
158
|
+
// If we are in a monorepo, we already wrote a merged tsconfig.json
|
|
159
159
|
if (file === 'tsconfig.json') {
|
|
160
160
|
return partOfMonorepo;
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
+
// We need to merge the project gitignore with the workspace one
|
|
164
|
+
if (file === '_gitignore') return partOfMonorepo;
|
|
165
|
+
|
|
163
166
|
// We need to make some adjustments the project’s package.json and
|
|
164
167
|
// quilt config file
|
|
165
168
|
if (file === 'package.json' || file === 'quilt.project.ts') return false;
|
|
@@ -168,6 +171,9 @@ async function createApp() {
|
|
|
168
171
|
let quiltProject = await appTemplate.read('quilt.project.ts');
|
|
169
172
|
if (!partOfMonorepo) {
|
|
170
173
|
quiltProject = quiltProject.replace('quiltApp', 'quiltWorkspace, quiltApp').replace('quiltApp(', 'quiltWorkspace(), quiltApp(');
|
|
174
|
+
if (await appTemplate.has('_gitignore')) {
|
|
175
|
+
await outputRoot.write(path__namespace.join(appDirectory, '.gitignore'), `${await outputRoot.read('.gitignore')}\n${await appTemplate.read('_gitignore')}`);
|
|
176
|
+
}
|
|
171
177
|
}
|
|
172
178
|
await outputRoot.write(path__namespace.join(appDirectory, 'quilt.project.ts'), await shared.format(quiltProject, {
|
|
173
179
|
as: 'typescript'
|
package/build/cjs/package.cjs
CHANGED
|
@@ -50,15 +50,11 @@ async function createProject() {
|
|
|
50
50
|
const args = getArguments();
|
|
51
51
|
if (args['--help']) {
|
|
52
52
|
const additionalOptions = stripIndent["default"]`
|
|
53
|
-
${index.cyan(`--description`)}, ${index.cyan(`--no-description`)}
|
|
53
|
+
${index.cyan(`--description [description]`)}, ${index.cyan(`--no-description`)}
|
|
54
54
|
A short description of the package. If you don’t provide this option, the command will ask
|
|
55
55
|
you for a description later.
|
|
56
56
|
${index.dim(`@see https://docs.npmjs.com/cli/v9/configuring-npm/package-json#description`)}
|
|
57
57
|
|
|
58
|
-
${index.cyan(`--react`)}, ${index.cyan(`--no-react`)}
|
|
59
|
-
Whether this package will use React. If you don’t provide this option, the command
|
|
60
|
-
will ask you about it later.
|
|
61
|
-
|
|
62
58
|
${index.cyan(`--public`)}, ${index.cyan(`--private`)}
|
|
63
59
|
Whether this package will be published for other projects to install. If you do not
|
|
64
60
|
provide this option, the command will ask you about it later.
|
|
@@ -68,9 +64,12 @@ async function createProject() {
|
|
|
68
64
|
this command will try to guess the correct repository to use based on existing packages.
|
|
69
65
|
${index.dim(`@see https://docs.npmjs.com/cli/v9/configuring-npm/package-json#repository`)}
|
|
70
66
|
|
|
71
|
-
${index.cyan(`--registry`)}
|
|
67
|
+
${index.cyan(`--registry [registry]`)}
|
|
72
68
|
The package registry to publish this package to. This option only applies if you create
|
|
73
69
|
a public package. If you do not provide this option, it will use the default NPM registry.
|
|
70
|
+
|
|
71
|
+
${index.cyan(`--react`)}
|
|
72
|
+
Whether this package will use React. Defaults to false.
|
|
74
73
|
`;
|
|
75
74
|
help.printHelp({
|
|
76
75
|
kind: 'package',
|
|
@@ -117,86 +116,36 @@ async function createProject() {
|
|
|
117
116
|
}
|
|
118
117
|
const rootDirectory = inWorkspace ? process.cwd() : directory;
|
|
119
118
|
const outputRoot = shared.createOutputTarget(rootDirectory);
|
|
120
|
-
const packageTemplate = shared.loadTemplate('package');
|
|
121
|
-
const workspaceTemplate = shared.loadTemplate('workspace');
|
|
122
|
-
|
|
123
|
-
// If we aren’t already in a workspace, copy the workspace files over, which
|
|
124
|
-
// are needed if we are making a monorepo or not.
|
|
125
|
-
if (!inWorkspace) {
|
|
119
|
+
const packageTemplate = shared.loadTemplate('package-simple');
|
|
120
|
+
const workspaceTemplate = shared.loadTemplate('workspace-simple');
|
|
121
|
+
if (createAsMonorepo) {
|
|
126
122
|
await workspaceTemplate.copy(directory, file => {
|
|
127
|
-
//
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
// We need to make some adjustments to the root package.json
|
|
131
|
-
if (file === 'package.json') return false;
|
|
132
|
-
return true;
|
|
123
|
+
// We will adjust the package.json before writing it
|
|
124
|
+
return file !== 'package.json';
|
|
133
125
|
});
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
workspacePackageJson.workspaces = [packageGlobRelativeToRoot];
|
|
143
|
-
if (packageManager$1.type === 'pnpm') {
|
|
144
|
-
await outputRoot.write('pnpm-workspace.yaml', await shared.format(`
|
|
145
|
-
packages:
|
|
146
|
-
- '${packageGlobRelativeToRoot}'
|
|
147
|
-
`, {
|
|
148
|
-
as: 'yaml'
|
|
149
|
-
}));
|
|
150
|
-
}
|
|
151
|
-
await outputRoot.write('package.json', await shared.format(JSON.stringify(workspacePackageJson), {
|
|
152
|
-
as: 'json-stringify'
|
|
153
|
-
}));
|
|
154
|
-
} else {
|
|
155
|
-
const [projectPackageJson, projectTSConfig, workspacePackageJson] = await Promise.all([packageTemplate.read('package.json').then(content => JSON.parse(content)), packageTemplate.read('tsconfig.json').then(content => JSON.parse(content)), workspaceTemplate.read('package.json').then(content => JSON.parse(content))]);
|
|
156
|
-
const mergedPackageJson = shared.mergeWorkspaceAndProjectPackageJsons(projectPackageJson, workspacePackageJson);
|
|
157
|
-
delete mergedPackageJson.workspaces;
|
|
158
|
-
adjustPackageJson(mergedPackageJson, {
|
|
159
|
-
name: shared.toValidPackageName(name),
|
|
160
|
-
description,
|
|
161
|
-
react: useReact,
|
|
162
|
-
isPublic,
|
|
163
|
-
registry: args['--registry']
|
|
164
|
-
});
|
|
165
|
-
await outputRoot.write('package.json', await shared.format(JSON.stringify(mergedPackageJson), {
|
|
166
|
-
as: 'json-stringify'
|
|
167
|
-
}));
|
|
168
|
-
await outputRoot.write('tsconfig.json', await shared.format(JSON.stringify(projectTSConfig), {
|
|
169
|
-
as: 'json'
|
|
126
|
+
const workspacePackageJson = JSON.parse(await workspaceTemplate.read('package.json'));
|
|
127
|
+
workspacePackageJson.name = shared.toValidPackageName(name);
|
|
128
|
+
if (packageManager$1.type === 'pnpm') {
|
|
129
|
+
await outputRoot.write('pnpm-workspace.yaml', await shared.format(`
|
|
130
|
+
packages:
|
|
131
|
+
- './packages/*'
|
|
132
|
+
`, {
|
|
133
|
+
as: 'yaml'
|
|
170
134
|
}));
|
|
171
135
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
}
|
|
175
|
-
if (setupExtras.has('vscode')) {
|
|
176
|
-
await shared.loadTemplate('vscode').copy(directory);
|
|
177
|
-
}
|
|
136
|
+
await outputRoot.write('package.json', await shared.format(JSON.stringify(workspacePackageJson), {
|
|
137
|
+
as: 'json-stringify'
|
|
138
|
+
}));
|
|
178
139
|
}
|
|
179
140
|
await packageTemplate.copy(packageDirectory, file => {
|
|
180
|
-
//
|
|
181
|
-
|
|
182
|
-
return partOfMonorepo;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
// We need to make some adjustments the project’s package.json, README, and Quilt config
|
|
186
|
-
return file !== 'package.json' && file !== 'quilt.project.ts' && file !== 'README.md';
|
|
141
|
+
// We will adjust the package.json and README.md before writing them
|
|
142
|
+
return file !== 'package.json' && file !== 'README.md';
|
|
187
143
|
});
|
|
188
|
-
let quiltProject = await packageTemplate.read('quilt.project.ts');
|
|
189
|
-
if (!partOfMonorepo) {
|
|
190
|
-
quiltProject = quiltProject.replace('quiltPackage', 'quiltWorkspace, quiltPackage').replace('quiltPackage(', 'quiltWorkspace(), quiltPackage(');
|
|
191
|
-
}
|
|
192
|
-
if (!useReact) {
|
|
193
|
-
quiltProject = quiltProject.replace('quiltPackage()', 'quiltPackage({react: false})');
|
|
194
|
-
}
|
|
195
|
-
await outputRoot.write(path__namespace.join(packageDirectory, 'quilt.project.ts'), await shared.format(quiltProject, {
|
|
196
|
-
as: 'typescript'
|
|
197
|
-
}));
|
|
198
144
|
await outputRoot.write(path__namespace.join(packageDirectory, 'README.md'), (await packageTemplate.read('README.md')).replaceAll('{{name}}', shared.toValidPackageName(name)));
|
|
199
145
|
if (partOfMonorepo) {
|
|
146
|
+
// Add the package to the workspace configuration files
|
|
147
|
+
await Promise.all([tsconfig.addToTsConfig(packageDirectory, outputRoot), packageManager.addToPackageManagerWorkspaces(packageDirectory, outputRoot, packageManager$1.type)]);
|
|
148
|
+
|
|
200
149
|
// Write the package’s package.json (the root one was already created)
|
|
201
150
|
const projectPackageJson = JSON.parse(await packageTemplate.read('package.json'));
|
|
202
151
|
if (repository === false) {
|
|
@@ -229,7 +178,29 @@ async function createProject() {
|
|
|
229
178
|
await outputRoot.write(path__namespace.join(packageDirectory, 'package.json'), await shared.format(JSON.stringify(projectPackageJson), {
|
|
230
179
|
as: 'json-stringify'
|
|
231
180
|
}));
|
|
232
|
-
|
|
181
|
+
} else {
|
|
182
|
+
// Write the package’s package.json by combining elements of the root and
|
|
183
|
+
// package templates
|
|
184
|
+
const [projectPackageJson, workspacePackageJson] = await Promise.all([packageTemplate.read('package.json').then(content => JSON.parse(content)), workspaceTemplate.read('package.json').then(content => JSON.parse(content))]);
|
|
185
|
+
const mergedPackageJson = shared.mergeWorkspaceAndProjectPackageJsons(projectPackageJson, workspacePackageJson);
|
|
186
|
+
adjustPackageJson(mergedPackageJson, {
|
|
187
|
+
name: shared.toValidPackageName(name),
|
|
188
|
+
description,
|
|
189
|
+
react: useReact,
|
|
190
|
+
isPublic,
|
|
191
|
+
registry: args['--registry']
|
|
192
|
+
});
|
|
193
|
+
await outputRoot.write('package.json', await shared.format(JSON.stringify(mergedPackageJson), {
|
|
194
|
+
as: 'json-stringify'
|
|
195
|
+
}));
|
|
196
|
+
}
|
|
197
|
+
if (!inWorkspace) {
|
|
198
|
+
if (setupExtras.has('github')) {
|
|
199
|
+
await shared.loadTemplate('github').copy(directory);
|
|
200
|
+
}
|
|
201
|
+
if (setupExtras.has('vscode')) {
|
|
202
|
+
await shared.loadTemplate('vscode').copy(directory);
|
|
203
|
+
}
|
|
233
204
|
}
|
|
234
205
|
if (shouldInstall) {
|
|
235
206
|
console.log();
|
|
@@ -316,7 +287,6 @@ function getArguments() {
|
|
|
316
287
|
'--extras': [String],
|
|
317
288
|
'--no-extras': Boolean,
|
|
318
289
|
'--react': Boolean,
|
|
319
|
-
'--no-react': Boolean,
|
|
320
290
|
'--public': Boolean,
|
|
321
291
|
'--private': Boolean,
|
|
322
292
|
'--registry': String,
|
|
@@ -420,19 +390,7 @@ async function getPublic(args) {
|
|
|
420
390
|
return isPublic;
|
|
421
391
|
}
|
|
422
392
|
async function getReact(args) {
|
|
423
|
-
|
|
424
|
-
if (args['--react'] || args['--yes']) {
|
|
425
|
-
useReact = true;
|
|
426
|
-
} else if (args['--no-react']) {
|
|
427
|
-
useReact = false;
|
|
428
|
-
} else {
|
|
429
|
-
useReact = await prompt.prompt({
|
|
430
|
-
type: 'confirm',
|
|
431
|
-
message: 'Will this package depend on React?',
|
|
432
|
-
initial: true
|
|
433
|
-
});
|
|
434
|
-
}
|
|
435
|
-
return useReact;
|
|
393
|
+
return Boolean(args['--react']);
|
|
436
394
|
}
|
|
437
395
|
function adjustPackageJson(packageJson, {
|
|
438
396
|
name,
|
|
@@ -480,7 +438,6 @@ function adjustPackageJson(packageJson, {
|
|
|
480
438
|
delete packageJson.devDependencies['react'];
|
|
481
439
|
delete packageJson.peerDependencies['react'];
|
|
482
440
|
delete packageJson.peerDependenciesMeta['react'];
|
|
483
|
-
packageJson.eslintConfig.extends = packageJson.eslintConfig.extends.filter(extend => !extend.includes('react'));
|
|
484
441
|
}
|
|
485
442
|
return packageJson;
|
|
486
443
|
}
|
|
@@ -52,7 +52,7 @@ async function getShouldInstall(argv) {
|
|
|
52
52
|
}
|
|
53
53
|
async function getPackageManager(argv, options) {
|
|
54
54
|
const packageManager$1 = await packageManager.getPackageManager(argv['--package-manager']);
|
|
55
|
-
return packageManager.createPackageManagerRunner(packageManager$1 ?? '
|
|
55
|
+
return packageManager.createPackageManagerRunner(packageManager$1 ?? 'pnpm', options);
|
|
56
56
|
}
|
|
57
57
|
const VALID_EXTRAS = new Set(['github', 'vscode']);
|
|
58
58
|
async function getExtrasToSetup(argv, {
|
package/build/cjs/shared.cjs
CHANGED
|
@@ -48,6 +48,11 @@ function loadTemplate(name) {
|
|
|
48
48
|
return fs__namespace.readFileSync(path__namespace.join(templateRoot, file), {
|
|
49
49
|
encoding: 'utf8'
|
|
50
50
|
});
|
|
51
|
+
},
|
|
52
|
+
async has(file) {
|
|
53
|
+
templateRootPromise ?? (templateRootPromise = templateDirectory(name));
|
|
54
|
+
const templateRoot = await templateRootPromise;
|
|
55
|
+
return fs__namespace.existsSync(path__namespace.join(templateRoot, file));
|
|
51
56
|
}
|
|
52
57
|
};
|
|
53
58
|
}
|
package/build/esm/app.mjs
CHANGED
|
@@ -133,11 +133,14 @@ async function createApp() {
|
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
await appTemplate.copy(appDirectory, file => {
|
|
136
|
-
// If we are in a monorepo, we
|
|
136
|
+
// If we are in a monorepo, we already wrote a merged tsconfig.json
|
|
137
137
|
if (file === 'tsconfig.json') {
|
|
138
138
|
return partOfMonorepo;
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
+
// We need to merge the project gitignore with the workspace one
|
|
142
|
+
if (file === '_gitignore') return partOfMonorepo;
|
|
143
|
+
|
|
141
144
|
// We need to make some adjustments the project’s package.json and
|
|
142
145
|
// quilt config file
|
|
143
146
|
if (file === 'package.json' || file === 'quilt.project.ts') return false;
|
|
@@ -146,6 +149,9 @@ async function createApp() {
|
|
|
146
149
|
let quiltProject = await appTemplate.read('quilt.project.ts');
|
|
147
150
|
if (!partOfMonorepo) {
|
|
148
151
|
quiltProject = quiltProject.replace('quiltApp', 'quiltWorkspace, quiltApp').replace('quiltApp(', 'quiltWorkspace(), quiltApp(');
|
|
152
|
+
if (await appTemplate.has('_gitignore')) {
|
|
153
|
+
await outputRoot.write(path.join(appDirectory, '.gitignore'), `${await outputRoot.read('.gitignore')}\n${await appTemplate.read('_gitignore')}`);
|
|
154
|
+
}
|
|
149
155
|
}
|
|
150
156
|
await outputRoot.write(path.join(appDirectory, 'quilt.project.ts'), await format(quiltProject, {
|
|
151
157
|
as: 'typescript'
|
package/build/esm/package.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as fs from 'node:fs';
|
|
2
2
|
import * as path from 'node:path';
|
|
3
3
|
import { printHelp } from './help.mjs';
|
|
4
|
-
import { toValidPackageName, emptyDirectory,
|
|
4
|
+
import { toValidPackageName, emptyDirectory, format, mergeWorkspaceAndProjectPackageJsons, loadTemplate, relativeDirectoryForDisplay, isEmpty, createOutputTarget } from './shared.mjs';
|
|
5
5
|
import { getInWorkspace, getCreateAsMonorepo, getExtrasToSetup, getShouldInstall, getPackageManager } from './shared/prompts.mjs';
|
|
6
6
|
import { addToTsConfig } from './shared/tsconfig.mjs';
|
|
7
7
|
import { addToPackageManagerWorkspaces } from './shared/package-manager.mjs';
|
|
@@ -28,15 +28,11 @@ async function createProject() {
|
|
|
28
28
|
const args = getArguments();
|
|
29
29
|
if (args['--help']) {
|
|
30
30
|
const additionalOptions = stripIndent`
|
|
31
|
-
${cyan_1(`--description`)}, ${cyan_1(`--no-description`)}
|
|
31
|
+
${cyan_1(`--description [description]`)}, ${cyan_1(`--no-description`)}
|
|
32
32
|
A short description of the package. If you don’t provide this option, the command will ask
|
|
33
33
|
you for a description later.
|
|
34
34
|
${dim_1(`@see https://docs.npmjs.com/cli/v9/configuring-npm/package-json#description`)}
|
|
35
35
|
|
|
36
|
-
${cyan_1(`--react`)}, ${cyan_1(`--no-react`)}
|
|
37
|
-
Whether this package will use React. If you don’t provide this option, the command
|
|
38
|
-
will ask you about it later.
|
|
39
|
-
|
|
40
36
|
${cyan_1(`--public`)}, ${cyan_1(`--private`)}
|
|
41
37
|
Whether this package will be published for other projects to install. If you do not
|
|
42
38
|
provide this option, the command will ask you about it later.
|
|
@@ -46,9 +42,12 @@ async function createProject() {
|
|
|
46
42
|
this command will try to guess the correct repository to use based on existing packages.
|
|
47
43
|
${dim_1(`@see https://docs.npmjs.com/cli/v9/configuring-npm/package-json#repository`)}
|
|
48
44
|
|
|
49
|
-
${cyan_1(`--registry`)}
|
|
45
|
+
${cyan_1(`--registry [registry]`)}
|
|
50
46
|
The package registry to publish this package to. This option only applies if you create
|
|
51
47
|
a public package. If you do not provide this option, it will use the default NPM registry.
|
|
48
|
+
|
|
49
|
+
${cyan_1(`--react`)}
|
|
50
|
+
Whether this package will use React. Defaults to false.
|
|
52
51
|
`;
|
|
53
52
|
printHelp({
|
|
54
53
|
kind: 'package',
|
|
@@ -95,86 +94,36 @@ async function createProject() {
|
|
|
95
94
|
}
|
|
96
95
|
const rootDirectory = inWorkspace ? process.cwd() : directory;
|
|
97
96
|
const outputRoot = createOutputTarget(rootDirectory);
|
|
98
|
-
const packageTemplate = loadTemplate('package');
|
|
99
|
-
const workspaceTemplate = loadTemplate('workspace');
|
|
100
|
-
|
|
101
|
-
// If we aren’t already in a workspace, copy the workspace files over, which
|
|
102
|
-
// are needed if we are making a monorepo or not.
|
|
103
|
-
if (!inWorkspace) {
|
|
97
|
+
const packageTemplate = loadTemplate('package-simple');
|
|
98
|
+
const workspaceTemplate = loadTemplate('workspace-simple');
|
|
99
|
+
if (createAsMonorepo) {
|
|
104
100
|
await workspaceTemplate.copy(directory, file => {
|
|
105
|
-
//
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
// We need to make some adjustments to the root package.json
|
|
109
|
-
if (file === 'package.json') return false;
|
|
110
|
-
return true;
|
|
101
|
+
// We will adjust the package.json before writing it
|
|
102
|
+
return file !== 'package.json';
|
|
111
103
|
});
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
workspacePackageJson.workspaces = [packageGlobRelativeToRoot];
|
|
121
|
-
if (packageManager.type === 'pnpm') {
|
|
122
|
-
await outputRoot.write('pnpm-workspace.yaml', await format(`
|
|
123
|
-
packages:
|
|
124
|
-
- '${packageGlobRelativeToRoot}'
|
|
125
|
-
`, {
|
|
126
|
-
as: 'yaml'
|
|
127
|
-
}));
|
|
128
|
-
}
|
|
129
|
-
await outputRoot.write('package.json', await format(JSON.stringify(workspacePackageJson), {
|
|
130
|
-
as: 'json-stringify'
|
|
131
|
-
}));
|
|
132
|
-
} else {
|
|
133
|
-
const [projectPackageJson, projectTSConfig, workspacePackageJson] = await Promise.all([packageTemplate.read('package.json').then(content => JSON.parse(content)), packageTemplate.read('tsconfig.json').then(content => JSON.parse(content)), workspaceTemplate.read('package.json').then(content => JSON.parse(content))]);
|
|
134
|
-
const mergedPackageJson = mergeWorkspaceAndProjectPackageJsons(projectPackageJson, workspacePackageJson);
|
|
135
|
-
delete mergedPackageJson.workspaces;
|
|
136
|
-
adjustPackageJson(mergedPackageJson, {
|
|
137
|
-
name: toValidPackageName(name),
|
|
138
|
-
description,
|
|
139
|
-
react: useReact,
|
|
140
|
-
isPublic,
|
|
141
|
-
registry: args['--registry']
|
|
142
|
-
});
|
|
143
|
-
await outputRoot.write('package.json', await format(JSON.stringify(mergedPackageJson), {
|
|
144
|
-
as: 'json-stringify'
|
|
145
|
-
}));
|
|
146
|
-
await outputRoot.write('tsconfig.json', await format(JSON.stringify(projectTSConfig), {
|
|
147
|
-
as: 'json'
|
|
104
|
+
const workspacePackageJson = JSON.parse(await workspaceTemplate.read('package.json'));
|
|
105
|
+
workspacePackageJson.name = toValidPackageName(name);
|
|
106
|
+
if (packageManager.type === 'pnpm') {
|
|
107
|
+
await outputRoot.write('pnpm-workspace.yaml', await format(`
|
|
108
|
+
packages:
|
|
109
|
+
- './packages/*'
|
|
110
|
+
`, {
|
|
111
|
+
as: 'yaml'
|
|
148
112
|
}));
|
|
149
113
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
153
|
-
if (setupExtras.has('vscode')) {
|
|
154
|
-
await loadTemplate('vscode').copy(directory);
|
|
155
|
-
}
|
|
114
|
+
await outputRoot.write('package.json', await format(JSON.stringify(workspacePackageJson), {
|
|
115
|
+
as: 'json-stringify'
|
|
116
|
+
}));
|
|
156
117
|
}
|
|
157
118
|
await packageTemplate.copy(packageDirectory, file => {
|
|
158
|
-
//
|
|
159
|
-
|
|
160
|
-
return partOfMonorepo;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
// We need to make some adjustments the project’s package.json, README, and Quilt config
|
|
164
|
-
return file !== 'package.json' && file !== 'quilt.project.ts' && file !== 'README.md';
|
|
119
|
+
// We will adjust the package.json and README.md before writing them
|
|
120
|
+
return file !== 'package.json' && file !== 'README.md';
|
|
165
121
|
});
|
|
166
|
-
let quiltProject = await packageTemplate.read('quilt.project.ts');
|
|
167
|
-
if (!partOfMonorepo) {
|
|
168
|
-
quiltProject = quiltProject.replace('quiltPackage', 'quiltWorkspace, quiltPackage').replace('quiltPackage(', 'quiltWorkspace(), quiltPackage(');
|
|
169
|
-
}
|
|
170
|
-
if (!useReact) {
|
|
171
|
-
quiltProject = quiltProject.replace('quiltPackage()', 'quiltPackage({react: false})');
|
|
172
|
-
}
|
|
173
|
-
await outputRoot.write(path.join(packageDirectory, 'quilt.project.ts'), await format(quiltProject, {
|
|
174
|
-
as: 'typescript'
|
|
175
|
-
}));
|
|
176
122
|
await outputRoot.write(path.join(packageDirectory, 'README.md'), (await packageTemplate.read('README.md')).replaceAll('{{name}}', toValidPackageName(name)));
|
|
177
123
|
if (partOfMonorepo) {
|
|
124
|
+
// Add the package to the workspace configuration files
|
|
125
|
+
await Promise.all([addToTsConfig(packageDirectory, outputRoot), addToPackageManagerWorkspaces(packageDirectory, outputRoot, packageManager.type)]);
|
|
126
|
+
|
|
178
127
|
// Write the package’s package.json (the root one was already created)
|
|
179
128
|
const projectPackageJson = JSON.parse(await packageTemplate.read('package.json'));
|
|
180
129
|
if (repository === false) {
|
|
@@ -207,7 +156,29 @@ async function createProject() {
|
|
|
207
156
|
await outputRoot.write(path.join(packageDirectory, 'package.json'), await format(JSON.stringify(projectPackageJson), {
|
|
208
157
|
as: 'json-stringify'
|
|
209
158
|
}));
|
|
210
|
-
|
|
159
|
+
} else {
|
|
160
|
+
// Write the package’s package.json by combining elements of the root and
|
|
161
|
+
// package templates
|
|
162
|
+
const [projectPackageJson, workspacePackageJson] = await Promise.all([packageTemplate.read('package.json').then(content => JSON.parse(content)), workspaceTemplate.read('package.json').then(content => JSON.parse(content))]);
|
|
163
|
+
const mergedPackageJson = mergeWorkspaceAndProjectPackageJsons(projectPackageJson, workspacePackageJson);
|
|
164
|
+
adjustPackageJson(mergedPackageJson, {
|
|
165
|
+
name: toValidPackageName(name),
|
|
166
|
+
description,
|
|
167
|
+
react: useReact,
|
|
168
|
+
isPublic,
|
|
169
|
+
registry: args['--registry']
|
|
170
|
+
});
|
|
171
|
+
await outputRoot.write('package.json', await format(JSON.stringify(mergedPackageJson), {
|
|
172
|
+
as: 'json-stringify'
|
|
173
|
+
}));
|
|
174
|
+
}
|
|
175
|
+
if (!inWorkspace) {
|
|
176
|
+
if (setupExtras.has('github')) {
|
|
177
|
+
await loadTemplate('github').copy(directory);
|
|
178
|
+
}
|
|
179
|
+
if (setupExtras.has('vscode')) {
|
|
180
|
+
await loadTemplate('vscode').copy(directory);
|
|
181
|
+
}
|
|
211
182
|
}
|
|
212
183
|
if (shouldInstall) {
|
|
213
184
|
console.log();
|
|
@@ -294,7 +265,6 @@ function getArguments() {
|
|
|
294
265
|
'--extras': [String],
|
|
295
266
|
'--no-extras': Boolean,
|
|
296
267
|
'--react': Boolean,
|
|
297
|
-
'--no-react': Boolean,
|
|
298
268
|
'--public': Boolean,
|
|
299
269
|
'--private': Boolean,
|
|
300
270
|
'--registry': String,
|
|
@@ -398,19 +368,7 @@ async function getPublic(args) {
|
|
|
398
368
|
return isPublic;
|
|
399
369
|
}
|
|
400
370
|
async function getReact(args) {
|
|
401
|
-
|
|
402
|
-
if (args['--react'] || args['--yes']) {
|
|
403
|
-
useReact = true;
|
|
404
|
-
} else if (args['--no-react']) {
|
|
405
|
-
useReact = false;
|
|
406
|
-
} else {
|
|
407
|
-
useReact = await prompt({
|
|
408
|
-
type: 'confirm',
|
|
409
|
-
message: 'Will this package depend on React?',
|
|
410
|
-
initial: true
|
|
411
|
-
});
|
|
412
|
-
}
|
|
413
|
-
return useReact;
|
|
371
|
+
return Boolean(args['--react']);
|
|
414
372
|
}
|
|
415
373
|
function adjustPackageJson(packageJson, {
|
|
416
374
|
name,
|
|
@@ -458,7 +416,6 @@ function adjustPackageJson(packageJson, {
|
|
|
458
416
|
delete packageJson.devDependencies['react'];
|
|
459
417
|
delete packageJson.peerDependencies['react'];
|
|
460
418
|
delete packageJson.peerDependenciesMeta['react'];
|
|
461
|
-
packageJson.eslintConfig.extends = packageJson.eslintConfig.extends.filter(extend => !extend.includes('react'));
|
|
462
419
|
}
|
|
463
420
|
return packageJson;
|
|
464
421
|
}
|
|
@@ -31,7 +31,7 @@ async function getShouldInstall(argv) {
|
|
|
31
31
|
}
|
|
32
32
|
async function getPackageManager(argv, options) {
|
|
33
33
|
const packageManager = await getPackageManager$1(argv['--package-manager']);
|
|
34
|
-
return createPackageManagerRunner(packageManager ?? '
|
|
34
|
+
return createPackageManagerRunner(packageManager ?? 'pnpm', options);
|
|
35
35
|
}
|
|
36
36
|
const VALID_EXTRAS = new Set(['github', 'vscode']);
|
|
37
37
|
async function getExtrasToSetup(argv, {
|
package/build/esm/shared.mjs
CHANGED
|
@@ -26,6 +26,11 @@ function loadTemplate(name) {
|
|
|
26
26
|
return fs.readFileSync(path.join(templateRoot, file), {
|
|
27
27
|
encoding: 'utf8'
|
|
28
28
|
});
|
|
29
|
+
},
|
|
30
|
+
async has(file) {
|
|
31
|
+
templateRootPromise ?? (templateRootPromise = templateDirectory(name));
|
|
32
|
+
const templateRoot = await templateRootPromise;
|
|
33
|
+
return fs.existsSync(path.join(templateRoot, file));
|
|
29
34
|
}
|
|
30
35
|
};
|
|
31
36
|
}
|
package/build/esnext/app.esnext
CHANGED
|
@@ -133,11 +133,14 @@ async function createApp() {
|
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
await appTemplate.copy(appDirectory, file => {
|
|
136
|
-
// If we are in a monorepo, we
|
|
136
|
+
// If we are in a monorepo, we already wrote a merged tsconfig.json
|
|
137
137
|
if (file === 'tsconfig.json') {
|
|
138
138
|
return partOfMonorepo;
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
+
// We need to merge the project gitignore with the workspace one
|
|
142
|
+
if (file === '_gitignore') return partOfMonorepo;
|
|
143
|
+
|
|
141
144
|
// We need to make some adjustments the project’s package.json and
|
|
142
145
|
// quilt config file
|
|
143
146
|
if (file === 'package.json' || file === 'quilt.project.ts') return false;
|
|
@@ -146,6 +149,9 @@ async function createApp() {
|
|
|
146
149
|
let quiltProject = await appTemplate.read('quilt.project.ts');
|
|
147
150
|
if (!partOfMonorepo) {
|
|
148
151
|
quiltProject = quiltProject.replace('quiltApp', 'quiltWorkspace, quiltApp').replace('quiltApp(', 'quiltWorkspace(), quiltApp(');
|
|
152
|
+
if (await appTemplate.has('_gitignore')) {
|
|
153
|
+
await outputRoot.write(path.join(appDirectory, '.gitignore'), `${await outputRoot.read('.gitignore')}\n${await appTemplate.read('_gitignore')}`);
|
|
154
|
+
}
|
|
149
155
|
}
|
|
150
156
|
await outputRoot.write(path.join(appDirectory, 'quilt.project.ts'), await format(quiltProject, {
|
|
151
157
|
as: 'typescript'
|