@quilted/create 0.1.87 → 0.1.89
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 +12 -0
- package/build/cjs/module.cjs +65 -100
- package/build/cjs/node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/prompts.cjs +1 -1
- package/build/cjs/node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/index.cjs +1 -1
- package/build/cjs/node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/prompts.cjs +1 -1
- package/build/cjs/package.cjs +1 -1
- package/build/cjs/shared.cjs +2 -1
- package/build/esm/module.mjs +65 -100
- package/build/esm/node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/prompts.mjs +1 -1
- package/build/esm/node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/index.mjs +1 -1
- package/build/esm/node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/prompts.mjs +1 -1
- package/build/esm/package.mjs +1 -1
- package/build/esnext/module.esnext +65 -100
- package/build/esnext/node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/prompts.esnext +1 -1
- package/build/esnext/node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/index.esnext +1 -1
- package/build/esnext/node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/prompts.esnext +1 -1
- package/build/esnext/package.esnext +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/build/typescript/module.d.ts.map +1 -1
- package/build/typescript/shared.d.ts +1 -1
- package/build/typescript/shared.d.ts.map +1 -1
- package/package.json +1 -1
- package/source/module.ts +99 -151
- package/source/package.ts +1 -1
- package/source/shared.ts +0 -2
- package/templates/module/module.ts +3 -1
- package/templates/module/package.json +6 -9
- package/templates/module/rollup.config.js +3 -0
- package/templates/module/tsconfig.json +1 -1
- package/templates/package/package.json +7 -11
- package/templates/package/tsconfig.json +1 -1
- package/templates/module/quilt.project.ts +0 -5
- package/templates/package/quilt.project.ts +0 -5
- package/templates/package/source/tests/index.test.ts +0 -8
- package/templates/package-simple/README.md +0 -1
- package/templates/package-simple/package.json +0 -49
- package/templates/package-simple/source/index.ts +0 -3
- package/templates/package-simple/tsconfig.json +0 -10
- /package/templates/{package-simple → package}/rollup.config.js +0 -0
- /package/templates/{package-simple → package}/source/index.test.ts +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @quilted/create
|
|
2
2
|
|
|
3
|
+
## 0.1.89
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`48beeccb`](https://github.com/lemonmade/quilt/commit/48beeccb4366c73ee1040221414af690ccba0958) Thanks [@lemonmade](https://github.com/lemonmade)! - Fix module template and rollup build
|
|
8
|
+
|
|
9
|
+
## 0.1.88
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`78f914d3`](https://github.com/lemonmade/quilt/commit/78f914d36e5a70b76ea9364529e9a00269065fb6) Thanks [@lemonmade](https://github.com/lemonmade)! - Add better module template
|
|
14
|
+
|
|
3
15
|
## 0.1.87
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/build/cjs/module.cjs
CHANGED
|
@@ -49,9 +49,18 @@ var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
|
|
|
49
49
|
async function createModule() {
|
|
50
50
|
const argv = getArgv();
|
|
51
51
|
if (argv['--help']) {
|
|
52
|
+
const additionalOptions = stripIndent["default"]`
|
|
53
|
+
${index.cyan(`--entry [entry]`)}
|
|
54
|
+
The entry file for your module. This should be a relative path from the root
|
|
55
|
+
of the project, and should include the file extension.
|
|
56
|
+
|
|
57
|
+
${index.cyan(`--react`)}
|
|
58
|
+
Whether this package will use React. Defaults to false.
|
|
59
|
+
`;
|
|
52
60
|
help.printHelp({
|
|
53
61
|
kind: 'module',
|
|
54
|
-
packageManager: argv['--package-manager']?.toLowerCase()
|
|
62
|
+
packageManager: argv['--package-manager']?.toLowerCase(),
|
|
63
|
+
options: additionalOptions
|
|
55
64
|
});
|
|
56
65
|
return;
|
|
57
66
|
}
|
|
@@ -92,99 +101,67 @@ async function createModule() {
|
|
|
92
101
|
const rootDirectory = inWorkspace ? process.cwd() : directory;
|
|
93
102
|
const outputRoot = shared.createOutputTarget(rootDirectory);
|
|
94
103
|
const moduleTemplate = shared.loadTemplate('module');
|
|
95
|
-
const workspaceTemplate = shared.loadTemplate('workspace');
|
|
96
|
-
|
|
97
|
-
// If we aren’t already in a workspace, copy the workspace files over, which
|
|
98
|
-
// are needed if we are making a monorepo or not.
|
|
99
|
-
if (!inWorkspace) {
|
|
104
|
+
const workspaceTemplate = shared.loadTemplate('workspace-simple');
|
|
105
|
+
if (createAsMonorepo) {
|
|
100
106
|
await workspaceTemplate.copy(directory, file => {
|
|
101
|
-
//
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
// We need to make some adjustments to the root package.json
|
|
105
|
-
if (file === 'package.json') return false;
|
|
106
|
-
return true;
|
|
107
|
+
// We will adjust the package.json before writing it
|
|
108
|
+
return file !== 'package.json';
|
|
107
109
|
});
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
if (
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
packages:
|
|
119
|
-
- '${moduleRelativeToRoot}'
|
|
120
|
-
- './packages/*'
|
|
121
|
-
`, {
|
|
122
|
-
as: 'yaml'
|
|
123
|
-
}));
|
|
124
|
-
}
|
|
125
|
-
await outputRoot.write('package.json', await shared.format(JSON.stringify(workspacePackageJson), {
|
|
126
|
-
as: 'json-stringify'
|
|
127
|
-
}));
|
|
128
|
-
} else {
|
|
129
|
-
const [projectPackageJson, projectTSConfig, workspacePackageJson] = await Promise.all([moduleTemplate.read('package.json').then(content => JSON.parse(content)), moduleTemplate.read('tsconfig.json').then(content => JSON.parse(content)), workspaceTemplate.read('package.json').then(content => JSON.parse(content))]);
|
|
130
|
-
const combinedPackageJson = shared.mergeWorkspaceAndProjectPackageJsons(projectPackageJson, workspacePackageJson);
|
|
131
|
-
adjustPackageJson(combinedPackageJson, {
|
|
132
|
-
name,
|
|
133
|
-
entry,
|
|
134
|
-
react: useReact
|
|
135
|
-
});
|
|
136
|
-
delete combinedPackageJson.workspaces;
|
|
137
|
-
await outputRoot.write('package.json', await shared.format(JSON.stringify(combinedPackageJson), {
|
|
138
|
-
as: 'json-stringify'
|
|
139
|
-
}));
|
|
140
|
-
await outputRoot.write('tsconfig.json', await shared.format(JSON.stringify(projectTSConfig), {
|
|
141
|
-
as: 'json'
|
|
110
|
+
const workspacePackageJson = JSON.parse(await workspaceTemplate.read('package.json'));
|
|
111
|
+
workspacePackageJson.name = shared.toValidPackageName(name);
|
|
112
|
+
const moduleRelativeToRoot = shared.relativeDirectoryForDisplay(path__namespace.relative(directory, moduleDirectory));
|
|
113
|
+
if (packageManager$1.type === 'pnpm') {
|
|
114
|
+
await outputRoot.write('pnpm-workspace.yaml', await shared.format(`
|
|
115
|
+
packages:
|
|
116
|
+
- './packages/*'
|
|
117
|
+
- '${moduleRelativeToRoot}'
|
|
118
|
+
`, {
|
|
119
|
+
as: 'yaml'
|
|
142
120
|
}));
|
|
143
121
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
}
|
|
147
|
-
if (setupExtras.has('vscode')) {
|
|
148
|
-
await shared.loadTemplate('vscode').copy(directory);
|
|
149
|
-
}
|
|
122
|
+
await outputRoot.write('package.json', await shared.format(JSON.stringify(workspacePackageJson), {
|
|
123
|
+
as: 'json-stringify'
|
|
124
|
+
}));
|
|
150
125
|
}
|
|
151
126
|
await moduleTemplate.copy(moduleDirectory, file => {
|
|
152
|
-
//
|
|
153
|
-
|
|
154
|
-
return partOfMonorepo;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
// We will adjust the entry file
|
|
158
|
-
if (file === 'module.ts') return false;
|
|
159
|
-
|
|
160
|
-
// We need to make some adjustments the project’s package.json and quilt
|
|
161
|
-
// config
|
|
162
|
-
if (file === 'package.json' || file === 'quilt.project.ts') return false;
|
|
163
|
-
return true;
|
|
127
|
+
// We will adjust the package.json before writing them
|
|
128
|
+
return file !== 'package.json';
|
|
164
129
|
});
|
|
165
|
-
let quiltProject = await moduleTemplate.read('quilt.project.ts');
|
|
166
|
-
if (!partOfMonorepo) {
|
|
167
|
-
quiltProject = quiltProject.replace('quiltModule', 'quiltWorkspace, quiltModule').replace('quiltModule(', 'quiltWorkspace(), quiltModule(');
|
|
168
|
-
}
|
|
169
|
-
if (!useReact) {
|
|
170
|
-
quiltProject = quiltProject.replace('quiltPackage()', 'quiltPackage({react: false})');
|
|
171
|
-
}
|
|
172
|
-
await outputRoot.write(path__namespace.join(moduleDirectory, 'quilt.project.ts'), await shared.format(quiltProject, {
|
|
173
|
-
as: 'typescript'
|
|
174
|
-
}));
|
|
175
|
-
await outputRoot.write(path__namespace.join(moduleDirectory, entry), await moduleTemplate.read('module.ts'));
|
|
176
130
|
if (partOfMonorepo) {
|
|
177
|
-
//
|
|
131
|
+
// Add the package to the workspace configuration files
|
|
132
|
+
await Promise.all([tsconfig.addToTsConfig(moduleDirectory, outputRoot), packageManager.addToPackageManagerWorkspaces(moduleDirectory, outputRoot, packageManager$1.type)]);
|
|
133
|
+
|
|
134
|
+
// Write the package’s package.json (the root one was already created)
|
|
178
135
|
const projectPackageJson = JSON.parse(await moduleTemplate.read('package.json'));
|
|
179
136
|
adjustPackageJson(projectPackageJson, {
|
|
180
|
-
name,
|
|
181
|
-
|
|
182
|
-
|
|
137
|
+
name: shared.toValidPackageName(name),
|
|
138
|
+
react: useReact,
|
|
139
|
+
entry
|
|
183
140
|
});
|
|
184
141
|
await outputRoot.write(path__namespace.join(moduleDirectory, 'package.json'), await shared.format(JSON.stringify(projectPackageJson), {
|
|
185
142
|
as: 'json-stringify'
|
|
186
143
|
}));
|
|
187
|
-
|
|
144
|
+
} else {
|
|
145
|
+
// Write the package’s package.json by combining elements of the root and
|
|
146
|
+
// package templates
|
|
147
|
+
const [projectPackageJson, workspacePackageJson] = await Promise.all([moduleTemplate.read('package.json').then(content => JSON.parse(content)), workspaceTemplate.read('package.json').then(content => JSON.parse(content))]);
|
|
148
|
+
const mergedPackageJson = shared.mergeWorkspaceAndProjectPackageJsons(projectPackageJson, workspacePackageJson);
|
|
149
|
+
adjustPackageJson(mergedPackageJson, {
|
|
150
|
+
name: shared.toValidPackageName(name),
|
|
151
|
+
react: useReact,
|
|
152
|
+
entry
|
|
153
|
+
});
|
|
154
|
+
await outputRoot.write('package.json', await shared.format(JSON.stringify(mergedPackageJson), {
|
|
155
|
+
as: 'json-stringify'
|
|
156
|
+
}));
|
|
157
|
+
}
|
|
158
|
+
if (!inWorkspace) {
|
|
159
|
+
if (setupExtras.has('github')) {
|
|
160
|
+
await shared.loadTemplate('github').copy(directory);
|
|
161
|
+
}
|
|
162
|
+
if (setupExtras.has('vscode')) {
|
|
163
|
+
await shared.loadTemplate('vscode').copy(directory);
|
|
164
|
+
}
|
|
188
165
|
}
|
|
189
166
|
if (shouldInstall) {
|
|
190
167
|
console.log();
|
|
@@ -239,7 +216,6 @@ function getArgv() {
|
|
|
239
216
|
'--extras': [String],
|
|
240
217
|
'--no-extras': Boolean,
|
|
241
218
|
'--react': Boolean,
|
|
242
|
-
'--no-react': Boolean,
|
|
243
219
|
'--help': Boolean,
|
|
244
220
|
'-h': '--help'
|
|
245
221
|
}, {
|
|
@@ -247,10 +223,12 @@ function getArgv() {
|
|
|
247
223
|
});
|
|
248
224
|
return argv;
|
|
249
225
|
}
|
|
250
|
-
async function getName(
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
226
|
+
async function getName(args) {
|
|
227
|
+
const {
|
|
228
|
+
_,
|
|
229
|
+
'--name': nameArgument
|
|
230
|
+
} = args;
|
|
231
|
+
let name = nameArgument ?? _[1];
|
|
254
232
|
if (name == null) {
|
|
255
233
|
name = await prompt.prompt({
|
|
256
234
|
type: 'text',
|
|
@@ -302,19 +280,7 @@ async function getDirectory(argv, {
|
|
|
302
280
|
return directory;
|
|
303
281
|
}
|
|
304
282
|
async function getReact(args) {
|
|
305
|
-
|
|
306
|
-
if (args['--react'] || args['--yes']) {
|
|
307
|
-
useReact = true;
|
|
308
|
-
} else if (args['--no-react']) {
|
|
309
|
-
useReact = false;
|
|
310
|
-
} else {
|
|
311
|
-
useReact = await prompt.prompt({
|
|
312
|
-
type: 'confirm',
|
|
313
|
-
message: 'Will this module depend on React?',
|
|
314
|
-
initial: false
|
|
315
|
-
});
|
|
316
|
-
}
|
|
317
|
-
return useReact;
|
|
283
|
+
return Boolean(args['--react']);
|
|
318
284
|
}
|
|
319
285
|
function adjustPackageJson(packageJson, {
|
|
320
286
|
name,
|
|
@@ -322,14 +288,13 @@ function adjustPackageJson(packageJson, {
|
|
|
322
288
|
react
|
|
323
289
|
}) {
|
|
324
290
|
packageJson.name = name;
|
|
325
|
-
packageJson.
|
|
291
|
+
packageJson.exports['.'] = `./${entry}`;
|
|
326
292
|
if (!react) {
|
|
327
293
|
delete packageJson.devDependencies['@types/react'];
|
|
328
294
|
delete packageJson.devDependencies['@types/react-dom'];
|
|
329
295
|
delete packageJson.devDependencies['preact'];
|
|
330
296
|
delete packageJson.devDependencies['react'];
|
|
331
297
|
delete packageJson.devDependencies['react-dom'];
|
|
332
|
-
packageJson.eslintConfig.extends = packageJson.eslintConfig.extends.filter(extend => !extend.includes('react'));
|
|
333
298
|
}
|
|
334
299
|
return packageJson;
|
|
335
300
|
}
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var _commonjsHelpers = require('../../../../../_virtual/_commonjsHelpers.cjs');
|
|
6
|
-
var index = require('./dist/index.cjs');
|
|
7
6
|
var index$1 = require('./lib/index.cjs');
|
|
7
|
+
var index = require('./dist/index.cjs');
|
|
8
8
|
|
|
9
9
|
function isNodeLT(tar) {
|
|
10
10
|
tar = (Array.isArray(tar) ? tar : tar.split('.')).map(Number);
|
package/build/cjs/package.cjs
CHANGED
|
@@ -116,7 +116,7 @@ async function createProject() {
|
|
|
116
116
|
}
|
|
117
117
|
const rootDirectory = inWorkspace ? process.cwd() : directory;
|
|
118
118
|
const outputRoot = shared.createOutputTarget(rootDirectory);
|
|
119
|
-
const packageTemplate = shared.loadTemplate('package
|
|
119
|
+
const packageTemplate = shared.loadTemplate('package');
|
|
120
120
|
const workspaceTemplate = shared.loadTemplate('workspace-simple');
|
|
121
121
|
if (createAsMonorepo) {
|
|
122
122
|
await workspaceTemplate.copy(directory, file => {
|
package/build/cjs/shared.cjs
CHANGED
|
@@ -4,6 +4,7 @@ var fs = require('node:fs');
|
|
|
4
4
|
var path = require('node:path');
|
|
5
5
|
var node_url = require('node:url');
|
|
6
6
|
|
|
7
|
+
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
7
8
|
function _interopNamespaceDefault(e) {
|
|
8
9
|
var n = Object.create(null);
|
|
9
10
|
if (e) {
|
|
@@ -80,7 +81,7 @@ async function getPackageRoot() {
|
|
|
80
81
|
packageDirectory
|
|
81
82
|
} = await Promise.resolve().then(function () { return require('./node_modules/.pnpm/pkg-dir@6.0.1/node_modules/pkg-dir/index.cjs'); });
|
|
82
83
|
return packageDirectory({
|
|
83
|
-
cwd: path__namespace.dirname(node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (
|
|
84
|
+
cwd: path__namespace.dirname(node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('shared.cjs', document.baseURI).href))))
|
|
84
85
|
});
|
|
85
86
|
})();
|
|
86
87
|
}
|
package/build/esm/module.mjs
CHANGED
|
@@ -27,9 +27,18 @@ import { prompt } from './packages/cli-kit/source/prompt.mjs';
|
|
|
27
27
|
async function createModule() {
|
|
28
28
|
const argv = getArgv();
|
|
29
29
|
if (argv['--help']) {
|
|
30
|
+
const additionalOptions = stripIndent`
|
|
31
|
+
${cyan_1(`--entry [entry]`)}
|
|
32
|
+
The entry file for your module. This should be a relative path from the root
|
|
33
|
+
of the project, and should include the file extension.
|
|
34
|
+
|
|
35
|
+
${cyan_1(`--react`)}
|
|
36
|
+
Whether this package will use React. Defaults to false.
|
|
37
|
+
`;
|
|
30
38
|
printHelp({
|
|
31
39
|
kind: 'module',
|
|
32
|
-
packageManager: argv['--package-manager']?.toLowerCase()
|
|
40
|
+
packageManager: argv['--package-manager']?.toLowerCase(),
|
|
41
|
+
options: additionalOptions
|
|
33
42
|
});
|
|
34
43
|
return;
|
|
35
44
|
}
|
|
@@ -70,99 +79,67 @@ async function createModule() {
|
|
|
70
79
|
const rootDirectory = inWorkspace ? process.cwd() : directory;
|
|
71
80
|
const outputRoot = createOutputTarget(rootDirectory);
|
|
72
81
|
const moduleTemplate = loadTemplate('module');
|
|
73
|
-
const workspaceTemplate = loadTemplate('workspace');
|
|
74
|
-
|
|
75
|
-
// If we aren’t already in a workspace, copy the workspace files over, which
|
|
76
|
-
// are needed if we are making a monorepo or not.
|
|
77
|
-
if (!inWorkspace) {
|
|
82
|
+
const workspaceTemplate = loadTemplate('workspace-simple');
|
|
83
|
+
if (createAsMonorepo) {
|
|
78
84
|
await workspaceTemplate.copy(directory, file => {
|
|
79
|
-
//
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
// We need to make some adjustments to the root package.json
|
|
83
|
-
if (file === 'package.json') return false;
|
|
84
|
-
return true;
|
|
85
|
+
// We will adjust the package.json before writing it
|
|
86
|
+
return file !== 'package.json';
|
|
85
87
|
});
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
if (
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
packages:
|
|
97
|
-
- '${moduleRelativeToRoot}'
|
|
98
|
-
- './packages/*'
|
|
99
|
-
`, {
|
|
100
|
-
as: 'yaml'
|
|
101
|
-
}));
|
|
102
|
-
}
|
|
103
|
-
await outputRoot.write('package.json', await format(JSON.stringify(workspacePackageJson), {
|
|
104
|
-
as: 'json-stringify'
|
|
105
|
-
}));
|
|
106
|
-
} else {
|
|
107
|
-
const [projectPackageJson, projectTSConfig, workspacePackageJson] = await Promise.all([moduleTemplate.read('package.json').then(content => JSON.parse(content)), moduleTemplate.read('tsconfig.json').then(content => JSON.parse(content)), workspaceTemplate.read('package.json').then(content => JSON.parse(content))]);
|
|
108
|
-
const combinedPackageJson = mergeWorkspaceAndProjectPackageJsons(projectPackageJson, workspacePackageJson);
|
|
109
|
-
adjustPackageJson(combinedPackageJson, {
|
|
110
|
-
name,
|
|
111
|
-
entry,
|
|
112
|
-
react: useReact
|
|
113
|
-
});
|
|
114
|
-
delete combinedPackageJson.workspaces;
|
|
115
|
-
await outputRoot.write('package.json', await format(JSON.stringify(combinedPackageJson), {
|
|
116
|
-
as: 'json-stringify'
|
|
117
|
-
}));
|
|
118
|
-
await outputRoot.write('tsconfig.json', await format(JSON.stringify(projectTSConfig), {
|
|
119
|
-
as: 'json'
|
|
88
|
+
const workspacePackageJson = JSON.parse(await workspaceTemplate.read('package.json'));
|
|
89
|
+
workspacePackageJson.name = toValidPackageName(name);
|
|
90
|
+
const moduleRelativeToRoot = relativeDirectoryForDisplay(path.relative(directory, moduleDirectory));
|
|
91
|
+
if (packageManager.type === 'pnpm') {
|
|
92
|
+
await outputRoot.write('pnpm-workspace.yaml', await format(`
|
|
93
|
+
packages:
|
|
94
|
+
- './packages/*'
|
|
95
|
+
- '${moduleRelativeToRoot}'
|
|
96
|
+
`, {
|
|
97
|
+
as: 'yaml'
|
|
120
98
|
}));
|
|
121
99
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}
|
|
125
|
-
if (setupExtras.has('vscode')) {
|
|
126
|
-
await loadTemplate('vscode').copy(directory);
|
|
127
|
-
}
|
|
100
|
+
await outputRoot.write('package.json', await format(JSON.stringify(workspacePackageJson), {
|
|
101
|
+
as: 'json-stringify'
|
|
102
|
+
}));
|
|
128
103
|
}
|
|
129
104
|
await moduleTemplate.copy(moduleDirectory, file => {
|
|
130
|
-
//
|
|
131
|
-
|
|
132
|
-
return partOfMonorepo;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
// We will adjust the entry file
|
|
136
|
-
if (file === 'module.ts') return false;
|
|
137
|
-
|
|
138
|
-
// We need to make some adjustments the project’s package.json and quilt
|
|
139
|
-
// config
|
|
140
|
-
if (file === 'package.json' || file === 'quilt.project.ts') return false;
|
|
141
|
-
return true;
|
|
105
|
+
// We will adjust the package.json before writing them
|
|
106
|
+
return file !== 'package.json';
|
|
142
107
|
});
|
|
143
|
-
let quiltProject = await moduleTemplate.read('quilt.project.ts');
|
|
144
|
-
if (!partOfMonorepo) {
|
|
145
|
-
quiltProject = quiltProject.replace('quiltModule', 'quiltWorkspace, quiltModule').replace('quiltModule(', 'quiltWorkspace(), quiltModule(');
|
|
146
|
-
}
|
|
147
|
-
if (!useReact) {
|
|
148
|
-
quiltProject = quiltProject.replace('quiltPackage()', 'quiltPackage({react: false})');
|
|
149
|
-
}
|
|
150
|
-
await outputRoot.write(path.join(moduleDirectory, 'quilt.project.ts'), await format(quiltProject, {
|
|
151
|
-
as: 'typescript'
|
|
152
|
-
}));
|
|
153
|
-
await outputRoot.write(path.join(moduleDirectory, entry), await moduleTemplate.read('module.ts'));
|
|
154
108
|
if (partOfMonorepo) {
|
|
155
|
-
//
|
|
109
|
+
// Add the package to the workspace configuration files
|
|
110
|
+
await Promise.all([addToTsConfig(moduleDirectory, outputRoot), addToPackageManagerWorkspaces(moduleDirectory, outputRoot, packageManager.type)]);
|
|
111
|
+
|
|
112
|
+
// Write the package’s package.json (the root one was already created)
|
|
156
113
|
const projectPackageJson = JSON.parse(await moduleTemplate.read('package.json'));
|
|
157
114
|
adjustPackageJson(projectPackageJson, {
|
|
158
|
-
name,
|
|
159
|
-
|
|
160
|
-
|
|
115
|
+
name: toValidPackageName(name),
|
|
116
|
+
react: useReact,
|
|
117
|
+
entry
|
|
161
118
|
});
|
|
162
119
|
await outputRoot.write(path.join(moduleDirectory, 'package.json'), await format(JSON.stringify(projectPackageJson), {
|
|
163
120
|
as: 'json-stringify'
|
|
164
121
|
}));
|
|
165
|
-
|
|
122
|
+
} else {
|
|
123
|
+
// Write the package’s package.json by combining elements of the root and
|
|
124
|
+
// package templates
|
|
125
|
+
const [projectPackageJson, workspacePackageJson] = await Promise.all([moduleTemplate.read('package.json').then(content => JSON.parse(content)), workspaceTemplate.read('package.json').then(content => JSON.parse(content))]);
|
|
126
|
+
const mergedPackageJson = mergeWorkspaceAndProjectPackageJsons(projectPackageJson, workspacePackageJson);
|
|
127
|
+
adjustPackageJson(mergedPackageJson, {
|
|
128
|
+
name: toValidPackageName(name),
|
|
129
|
+
react: useReact,
|
|
130
|
+
entry
|
|
131
|
+
});
|
|
132
|
+
await outputRoot.write('package.json', await format(JSON.stringify(mergedPackageJson), {
|
|
133
|
+
as: 'json-stringify'
|
|
134
|
+
}));
|
|
135
|
+
}
|
|
136
|
+
if (!inWorkspace) {
|
|
137
|
+
if (setupExtras.has('github')) {
|
|
138
|
+
await loadTemplate('github').copy(directory);
|
|
139
|
+
}
|
|
140
|
+
if (setupExtras.has('vscode')) {
|
|
141
|
+
await loadTemplate('vscode').copy(directory);
|
|
142
|
+
}
|
|
166
143
|
}
|
|
167
144
|
if (shouldInstall) {
|
|
168
145
|
console.log();
|
|
@@ -217,7 +194,6 @@ function getArgv() {
|
|
|
217
194
|
'--extras': [String],
|
|
218
195
|
'--no-extras': Boolean,
|
|
219
196
|
'--react': Boolean,
|
|
220
|
-
'--no-react': Boolean,
|
|
221
197
|
'--help': Boolean,
|
|
222
198
|
'-h': '--help'
|
|
223
199
|
}, {
|
|
@@ -225,10 +201,12 @@ function getArgv() {
|
|
|
225
201
|
});
|
|
226
202
|
return argv;
|
|
227
203
|
}
|
|
228
|
-
async function getName(
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
204
|
+
async function getName(args) {
|
|
205
|
+
const {
|
|
206
|
+
_,
|
|
207
|
+
'--name': nameArgument
|
|
208
|
+
} = args;
|
|
209
|
+
let name = nameArgument ?? _[1];
|
|
232
210
|
if (name == null) {
|
|
233
211
|
name = await prompt({
|
|
234
212
|
type: 'text',
|
|
@@ -280,19 +258,7 @@ async function getDirectory(argv, {
|
|
|
280
258
|
return directory;
|
|
281
259
|
}
|
|
282
260
|
async function getReact(args) {
|
|
283
|
-
|
|
284
|
-
if (args['--react'] || args['--yes']) {
|
|
285
|
-
useReact = true;
|
|
286
|
-
} else if (args['--no-react']) {
|
|
287
|
-
useReact = false;
|
|
288
|
-
} else {
|
|
289
|
-
useReact = await prompt({
|
|
290
|
-
type: 'confirm',
|
|
291
|
-
message: 'Will this module depend on React?',
|
|
292
|
-
initial: false
|
|
293
|
-
});
|
|
294
|
-
}
|
|
295
|
-
return useReact;
|
|
261
|
+
return Boolean(args['--react']);
|
|
296
262
|
}
|
|
297
263
|
function adjustPackageJson(packageJson, {
|
|
298
264
|
name,
|
|
@@ -300,14 +266,13 @@ function adjustPackageJson(packageJson, {
|
|
|
300
266
|
react
|
|
301
267
|
}) {
|
|
302
268
|
packageJson.name = name;
|
|
303
|
-
packageJson.
|
|
269
|
+
packageJson.exports['.'] = `./${entry}`;
|
|
304
270
|
if (!react) {
|
|
305
271
|
delete packageJson.devDependencies['@types/react'];
|
|
306
272
|
delete packageJson.devDependencies['@types/react-dom'];
|
|
307
273
|
delete packageJson.devDependencies['preact'];
|
|
308
274
|
delete packageJson.devDependencies['react'];
|
|
309
275
|
delete packageJson.devDependencies['react-dom'];
|
|
310
|
-
packageJson.eslintConfig.extends = packageJson.eslintConfig.extends.filter(extend => !extend.includes('react'));
|
|
311
276
|
}
|
|
312
277
|
return packageJson;
|
|
313
278
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getDefaultExportFromCjs } from '../../../../../_virtual/_commonjsHelpers.mjs';
|
|
2
|
-
import { __require as requireDist } from './dist/index.mjs';
|
|
3
2
|
import { __require as requireLib } from './lib/index.mjs';
|
|
3
|
+
import { __require as requireDist } from './dist/index.mjs';
|
|
4
4
|
|
|
5
5
|
function isNodeLT(tar) {
|
|
6
6
|
tar = (Array.isArray(tar) ? tar : tar.split('.')).map(Number);
|
package/build/esm/package.mjs
CHANGED
|
@@ -94,7 +94,7 @@ async function createProject() {
|
|
|
94
94
|
}
|
|
95
95
|
const rootDirectory = inWorkspace ? process.cwd() : directory;
|
|
96
96
|
const outputRoot = createOutputTarget(rootDirectory);
|
|
97
|
-
const packageTemplate = loadTemplate('package
|
|
97
|
+
const packageTemplate = loadTemplate('package');
|
|
98
98
|
const workspaceTemplate = loadTemplate('workspace-simple');
|
|
99
99
|
if (createAsMonorepo) {
|
|
100
100
|
await workspaceTemplate.copy(directory, file => {
|