@quilted/create 0.1.17 → 0.1.20
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 +20 -0
- package/README.md +30 -0
- package/build/tsconfig.tsbuildinfo +1 -1
- package/build/typescript/app.d.ts.map +1 -1
- package/build/typescript/package.d.ts +1 -1
- package/build/typescript/package.d.ts.map +1 -1
- package/package.json +5 -3
- package/quilt.project.ts +19 -5
- package/source/app.ts +0 -10
- package/source/create.ts +2 -2
- package/source/package.ts +6 -11
- package/templates/app-basic/features/Start/Start.test.tsx +12 -0
- package/templates/app-basic/foundation/Head/Head.test.tsx +25 -0
- package/templates/app-basic/foundation/{Head.tsx → Head/Head.tsx} +0 -0
- package/templates/app-basic/foundation/Head/index.ts +1 -0
- package/templates/app-basic/foundation/Http/Http.test.tsx +24 -0
- package/templates/app-basic/foundation/{Http.tsx → Http/Http.tsx} +0 -0
- package/templates/app-basic/foundation/Http/index.ts +1 -0
- package/templates/app-basic/quilt.project.ts +5 -5
- package/templates/app-basic/tests/mount.tsx +47 -0
- package/templates/app-basic/tsconfig.json +4 -3
- package/templates/app-single-file/quilt.project.ts +3 -4
- package/templates/app-single-file/tsconfig.json +2 -2
- package/templates/package/package.json +4 -2
- package/templates/package/quilt.project.ts +3 -4
- package/templates/package/source/index.ts +3 -1
- package/templates/package/source/tests/index.test.ts +8 -0
- package/templates/package/tsconfig.json +2 -2
- package/templates/workspace/package.json +1 -1
- package/tsconfig.json +1 -1
- package/bin/create-quilt.mjs +0 -2
- package/build/cjs/_commonjsHelpers.cjs +0 -10
- package/build/cjs/app.cjs +0 -303
- package/build/cjs/index.cjs +0 -6784
- package/build/cjs/index2.cjs +0 -374
- package/build/cjs/index3.cjs +0 -7854
- package/build/cjs/minimatch.cjs +0 -1202
- package/build/cjs/package-manager.cjs +0 -305
- package/build/cjs/package.cjs +0 -424
- package/build/cjs/parser-babel.cjs +0 -59
- package/build/cjs/parser-yaml.cjs +0 -182
- package/build/cjs/standalone.cjs +0 -147
- package/build/esm/_commonjsHelpers.mjs +0 -7
- package/build/esm/app.mjs +0 -280
- package/build/esm/index.mjs +0 -6743
- package/build/esm/index2.mjs +0 -365
- package/build/esm/index3.mjs +0 -7852
- package/build/esm/minimatch.mjs +0 -1200
- package/build/esm/package-manager.mjs +0 -275
- package/build/esm/package.mjs +0 -401
- package/build/esm/parser-babel.mjs +0 -57
- package/build/esm/parser-yaml.mjs +0 -180
- package/build/esm/standalone.mjs +0 -145
package/build/cjs/package.cjs
DELETED
|
@@ -1,424 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var fs = require('fs');
|
|
4
|
-
var path = require('path');
|
|
5
|
-
var child_process = require('child_process');
|
|
6
|
-
var index = require('./index.cjs');
|
|
7
|
-
var packageManager = require('./package-manager.cjs');
|
|
8
|
-
require('tty');
|
|
9
|
-
require('url');
|
|
10
|
-
require('readline');
|
|
11
|
-
require('events');
|
|
12
|
-
|
|
13
|
-
function _interopNamespace(e) {
|
|
14
|
-
if (e && e.__esModule) return e;
|
|
15
|
-
var n = Object.create(null);
|
|
16
|
-
if (e) {
|
|
17
|
-
Object.keys(e).forEach(function (k) {
|
|
18
|
-
if (k !== 'default') {
|
|
19
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
20
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
21
|
-
enumerable: true,
|
|
22
|
-
get: function () { return e[k]; }
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
n["default"] = e;
|
|
28
|
-
return Object.freeze(n);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
var fs__namespace = /*#__PURE__*/_interopNamespace(fs);
|
|
32
|
-
var path__namespace = /*#__PURE__*/_interopNamespace(path);
|
|
33
|
-
|
|
34
|
-
async function createPackage() {
|
|
35
|
-
const argv = getArgv();
|
|
36
|
-
|
|
37
|
-
if (argv['--help']) {
|
|
38
|
-
const additionalOptions = index.stripIndent`
|
|
39
|
-
${index.cyan_1(`--react`)}, ${index.cyan_1(`--no-react`)}
|
|
40
|
-
Whether this package will use React. If you don’t provide this option, the command
|
|
41
|
-
will ask you about it later.
|
|
42
|
-
|
|
43
|
-
${index.cyan_1(`--public`)}, ${index.cyan_1(`--private`)}
|
|
44
|
-
Whether this package will be published for other projects to install. If you do not
|
|
45
|
-
provide this option, the command will ask you about it later.
|
|
46
|
-
|
|
47
|
-
${index.cyan_1(`--registry`)}
|
|
48
|
-
The package registry to publish this package to. This option only applies if you create
|
|
49
|
-
a public package. If you do not provide this option, it will use the default NPM registry.
|
|
50
|
-
`;
|
|
51
|
-
index.printHelp({
|
|
52
|
-
kind: 'package',
|
|
53
|
-
options: additionalOptions,
|
|
54
|
-
packageManager: argv['--package-manager']?.toLowerCase()
|
|
55
|
-
});
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const inWorkspace = fs__namespace.existsSync('quilt.workspace.ts');
|
|
60
|
-
const name = await getName(argv);
|
|
61
|
-
const directory = await getDirectory(argv, {
|
|
62
|
-
name,
|
|
63
|
-
inWorkspace
|
|
64
|
-
});
|
|
65
|
-
const isPublic = await getPublic(argv);
|
|
66
|
-
const useReact = await getReact(argv);
|
|
67
|
-
const createAsMonorepo = !inWorkspace && (await index.getCreateAsMonorepo(argv));
|
|
68
|
-
const shouldInstall = await index.getShouldInstall(argv);
|
|
69
|
-
const packageManager$1 = await index.getPackageManager(argv);
|
|
70
|
-
const setupExtras = await index.getExtrasToSetup(argv, {
|
|
71
|
-
inWorkspace
|
|
72
|
-
});
|
|
73
|
-
const partOfMonorepo = inWorkspace || createAsMonorepo;
|
|
74
|
-
const packageDirectory = createAsMonorepo ? path__namespace.join(directory, `packages/${packageManager.toValidPackageName(name.split('/').pop())}`) : directory;
|
|
75
|
-
|
|
76
|
-
if (fs__namespace.existsSync(directory)) {
|
|
77
|
-
await packageManager.emptyDirectory(directory);
|
|
78
|
-
|
|
79
|
-
if (packageDirectory !== directory) {
|
|
80
|
-
fs__namespace.mkdirSync(packageDirectory, {
|
|
81
|
-
recursive: true
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
} else {
|
|
85
|
-
fs__namespace.mkdirSync(packageDirectory, {
|
|
86
|
-
recursive: true
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
const rootDirectory = inWorkspace ? process.cwd() : directory;
|
|
91
|
-
const outputRoot = packageManager.createOutputTarget(rootDirectory);
|
|
92
|
-
const packageTemplate = packageManager.loadTemplate('package');
|
|
93
|
-
const workspaceTemplate = packageManager.loadTemplate('workspace');
|
|
94
|
-
let quiltProject = await packageTemplate.read('quilt.project.ts');
|
|
95
|
-
|
|
96
|
-
if (useReact) {
|
|
97
|
-
quiltProject = quiltProject.replace('react: false', 'react: true');
|
|
98
|
-
} // If we aren’t already in a workspace, copy the workspace files over, which
|
|
99
|
-
// are needed if we are making a monorepo or not.
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
if (!inWorkspace) {
|
|
103
|
-
await workspaceTemplate.copy(directory, file => {
|
|
104
|
-
// When this is a single project, we use the project’s Quilt configuration as the base.
|
|
105
|
-
if (file === 'quilt.workspace.ts') return createAsMonorepo; // We need to make some adjustments to the root package.json
|
|
106
|
-
|
|
107
|
-
return file !== 'package.json';
|
|
108
|
-
}); // If we are creating a monorepo, we need to add the root package.json and
|
|
109
|
-
// package manager workspace configuration.
|
|
110
|
-
|
|
111
|
-
if (createAsMonorepo) {
|
|
112
|
-
const workspacePackageJson = JSON.parse(await workspaceTemplate.read('package.json'));
|
|
113
|
-
workspacePackageJson.name = packageManager.toValidPackageName(name);
|
|
114
|
-
|
|
115
|
-
if (packageManager$1 === 'pnpm') {
|
|
116
|
-
await outputRoot.write('pnpm-workspace.yaml', await packageManager.format(`
|
|
117
|
-
packages:
|
|
118
|
-
- './packages/*'
|
|
119
|
-
`, {
|
|
120
|
-
as: 'yaml'
|
|
121
|
-
}));
|
|
122
|
-
} else {
|
|
123
|
-
workspacePackageJson.workspaces = ['packages/*'];
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
await outputRoot.write('package.json', await packageManager.format(JSON.stringify(workspacePackageJson), {
|
|
127
|
-
as: 'json-stringify'
|
|
128
|
-
}));
|
|
129
|
-
} else {
|
|
130
|
-
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))]);
|
|
131
|
-
workspacePackageJson.eslintConfig = projectPackageJson.eslintConfig;
|
|
132
|
-
workspacePackageJson.browserslist = projectPackageJson.browserslist;
|
|
133
|
-
const newPackageJson = {}; // We want to put the project’s dependencies in the package.json, respecting
|
|
134
|
-
// the preferred ordering (dependencies, peer dependencies, dev dependencies).
|
|
135
|
-
|
|
136
|
-
for (const [key, value] of Object.entries(projectPackageJson)) {
|
|
137
|
-
if (key !== 'devDependencies') {
|
|
138
|
-
newPackageJson[key] = value;
|
|
139
|
-
continue;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
newPackageJson.dependencies = projectPackageJson.dependencies;
|
|
143
|
-
newPackageJson.peerDependencies = projectPackageJson.peerDependencies;
|
|
144
|
-
newPackageJson.peerDependenciesMeta = projectPackageJson.peerDependenciesMeta;
|
|
145
|
-
newPackageJson.devDependencies = sortKeys({ ...workspacePackageJson.devDependencies,
|
|
146
|
-
...projectPackageJson.devDependencies
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
adjustPackageJson(newPackageJson, {
|
|
151
|
-
name: packageManager.toValidPackageName(name),
|
|
152
|
-
react: useReact,
|
|
153
|
-
isPublic,
|
|
154
|
-
registry: argv['--registry']
|
|
155
|
-
});
|
|
156
|
-
const addBackToTSConfigInclude = new Set(['quilt.project.ts', '*.test.ts', '*.test.tsx']);
|
|
157
|
-
projectTSConfig.exclude = projectTSConfig.exclude.filter(excluded => !addBackToTSConfigInclude.has(excluded));
|
|
158
|
-
quiltProject = quiltProject.replace('quiltPackage', 'quiltWorkspace, quiltPackage').replace('quiltPackage(', 'quiltWorkspace(), quiltPackage(');
|
|
159
|
-
await outputRoot.write('quilt.project.ts', await packageManager.format(quiltProject, {
|
|
160
|
-
as: 'typescript'
|
|
161
|
-
}));
|
|
162
|
-
await outputRoot.write('package.json', await packageManager.format(JSON.stringify(newPackageJson), {
|
|
163
|
-
as: 'json-stringify'
|
|
164
|
-
}));
|
|
165
|
-
await outputRoot.write('tsconfig.json', await packageManager.format(JSON.stringify(projectTSConfig), {
|
|
166
|
-
as: 'json'
|
|
167
|
-
}));
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
if (setupExtras.has('github')) {
|
|
171
|
-
await packageManager.loadTemplate('github').copy(directory);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
if (setupExtras.has('vscode')) {
|
|
175
|
-
await packageManager.loadTemplate('vscode').copy(directory);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
await packageTemplate.copy(packageDirectory, file => {
|
|
180
|
-
// If we are in a monorepo, we can use all the template files as they are
|
|
181
|
-
if (file === 'tsconfig.json') {
|
|
182
|
-
return partOfMonorepo;
|
|
183
|
-
} // We need to make some adjustments the project’s package.json and Quilt config
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
return file !== 'package.json' && file !== 'quilt.project.ts';
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
if (partOfMonorepo) {
|
|
190
|
-
// Write the package’s package.json (the root one was already created)
|
|
191
|
-
const projectPackageJson = JSON.parse(await packageTemplate.read('package.json'));
|
|
192
|
-
projectPackageJson.repository.directory = path__namespace.relative(directory, packageDirectory);
|
|
193
|
-
adjustPackageJson(projectPackageJson, {
|
|
194
|
-
name: packageManager.toValidPackageName(name),
|
|
195
|
-
react: useReact,
|
|
196
|
-
isPublic,
|
|
197
|
-
registry: argv['--registry']
|
|
198
|
-
});
|
|
199
|
-
await outputRoot.write(path__namespace.join(packageDirectory, 'package.json'), await packageManager.format(JSON.stringify(projectPackageJson), {
|
|
200
|
-
as: 'json-stringify'
|
|
201
|
-
}));
|
|
202
|
-
await outputRoot.write(path__namespace.join(packageDirectory, 'quilt.project.ts'), quiltProject);
|
|
203
|
-
await Promise.all([packageManager.addToTsConfig(packageDirectory, outputRoot), packageManager.addToPackageManagerWorkspaces(packageDirectory, outputRoot, packageManager$1)]);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
if (shouldInstall) {
|
|
207
|
-
process.stdout.write('\nInstalling dependencies...\n'); // TODO: better loading, handle errors
|
|
208
|
-
|
|
209
|
-
child_process.execSync(`${packageManager$1} install`, {
|
|
210
|
-
cwd: rootDirectory
|
|
211
|
-
});
|
|
212
|
-
process.stdout.moveCursor(0, -1);
|
|
213
|
-
process.stdout.clearLine(1);
|
|
214
|
-
console.log('Installed dependencies.');
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
const packageJsonInstructions = index.stripIndent`
|
|
218
|
-
Your new package is ready to go! However, before you go too much further,
|
|
219
|
-
you should update the following fields in ${index.cyan_1(packageManager.relativeDirectoryForDisplay(path__namespace.relative(process.cwd(), path__namespace.join(packageDirectory, 'package.json'))))}:
|
|
220
|
-
|
|
221
|
-
- ${index.bold_1(`"description"`)}, where you provide a description of what your package does
|
|
222
|
-
- ${index.bold_1(`"repository"`)}, where you should include the ${index.bold_1(`"url"`)} of your project’s repo
|
|
223
|
-
`;
|
|
224
|
-
console.log();
|
|
225
|
-
console.log(packageJsonInstructions);
|
|
226
|
-
const commands = [];
|
|
227
|
-
|
|
228
|
-
if (!inWorkspace && directory !== process.cwd()) {
|
|
229
|
-
commands.push(`cd ${index.cyan_1(packageManager.relativeDirectoryForDisplay(path__namespace.relative(process.cwd(), directory)))} ${index.dim_1('# Move into your new package’s directory')}`);
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
if (!shouldInstall) {
|
|
233
|
-
commands.push(`pnpm install ${index.dim_1('# Install all your dependencies')}`);
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
if (!inWorkspace) {
|
|
237
|
-
// TODO: change this condition to check if git was initialized already
|
|
238
|
-
commands.push(`git init && git add -A && git commit -m "Initial commit" ${index.dim_1('# Start your git history (optional)')}`);
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
if (commands.length > 0) {
|
|
242
|
-
const whatsNext = index.stripIndent`
|
|
243
|
-
After you update your package.json, there’s ${commands.length > 1 ? 'a few more steps' : 'one more step'} you’ll need to take
|
|
244
|
-
in order to start building:
|
|
245
|
-
`;
|
|
246
|
-
console.log();
|
|
247
|
-
console.log(whatsNext);
|
|
248
|
-
console.log();
|
|
249
|
-
console.log(commands.map(command => ` ${command}`).join('\n'));
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
const followUp = index.stripIndent`
|
|
253
|
-
Quilt can help you build, test, lint, and type-check your new package. You
|
|
254
|
-
can learn more about building packages with Quilt by reading the documentation:
|
|
255
|
-
${index.underline_1(index.magenta_1('https://github.com/lemonmade/quilt/tree/main/documentation'))}
|
|
256
|
-
|
|
257
|
-
Have fun! 🎉
|
|
258
|
-
`;
|
|
259
|
-
console.log();
|
|
260
|
-
console.log(followUp);
|
|
261
|
-
} // Argument handling
|
|
262
|
-
|
|
263
|
-
function getArgv() {
|
|
264
|
-
const argv = index.arg_1({
|
|
265
|
-
'--yes': Boolean,
|
|
266
|
-
'-y': '--yes',
|
|
267
|
-
'--name': String,
|
|
268
|
-
'--directory': String,
|
|
269
|
-
'--install': Boolean,
|
|
270
|
-
'--no-install': Boolean,
|
|
271
|
-
'--monorepo': Boolean,
|
|
272
|
-
'--no-monorepo': Boolean,
|
|
273
|
-
'--package-manager': String,
|
|
274
|
-
'--extras': [String],
|
|
275
|
-
'--no-extras': Boolean,
|
|
276
|
-
'--react': Boolean,
|
|
277
|
-
'--no-react': Boolean,
|
|
278
|
-
'--public': Boolean,
|
|
279
|
-
'--private': Boolean,
|
|
280
|
-
'--registry': String,
|
|
281
|
-
'--help': Boolean,
|
|
282
|
-
'-h': '--help'
|
|
283
|
-
}, {
|
|
284
|
-
permissive: true
|
|
285
|
-
});
|
|
286
|
-
return argv;
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
async function getName(argv) {
|
|
290
|
-
let {
|
|
291
|
-
'--name': name
|
|
292
|
-
} = argv;
|
|
293
|
-
|
|
294
|
-
if (name == null) {
|
|
295
|
-
name = await index.prompt({
|
|
296
|
-
type: 'text',
|
|
297
|
-
message: 'What would you like to name your new package?',
|
|
298
|
-
initial: '@my-team/package'
|
|
299
|
-
});
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
return name;
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
async function getDirectory(argv, {
|
|
306
|
-
name,
|
|
307
|
-
inWorkspace
|
|
308
|
-
}) {
|
|
309
|
-
let directory = argv['--directory'] ? path__namespace.resolve(argv['--directory']) : undefined;
|
|
310
|
-
|
|
311
|
-
if (directory == null) {
|
|
312
|
-
const basePackageName = packageManager.toValidPackageName(name.split('/').pop());
|
|
313
|
-
const defaultDirectory = inWorkspace ? `packages/${basePackageName}` : basePackageName;
|
|
314
|
-
directory = path__namespace.resolve(await index.prompt({
|
|
315
|
-
type: 'text',
|
|
316
|
-
message: 'Where would you like to create your new package?',
|
|
317
|
-
initial: defaultDirectory
|
|
318
|
-
}));
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
while (!argv['--yes']) {
|
|
322
|
-
if (fs__namespace.existsSync(directory) && !(await packageManager.isEmpty(directory))) {
|
|
323
|
-
const relativeDirectory = path__namespace.relative(process.cwd(), directory);
|
|
324
|
-
const empty = await index.prompt({
|
|
325
|
-
type: 'confirm',
|
|
326
|
-
message: `Directory ${index.bold_1(packageManager.relativeDirectoryForDisplay(relativeDirectory))} is not empty, is it safe to empty it?`,
|
|
327
|
-
initial: true
|
|
328
|
-
});
|
|
329
|
-
if (empty) break;
|
|
330
|
-
const promptDirectory = await index.prompt({
|
|
331
|
-
type: 'text',
|
|
332
|
-
message: 'What directory do you want to create your package in?'
|
|
333
|
-
});
|
|
334
|
-
directory = path__namespace.resolve(promptDirectory);
|
|
335
|
-
} else {
|
|
336
|
-
break;
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
return directory;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
async function getPublic(argv) {
|
|
344
|
-
let isPublic;
|
|
345
|
-
|
|
346
|
-
if (argv['--public'] || argv['--yes']) {
|
|
347
|
-
isPublic = true;
|
|
348
|
-
} else if (argv['--private']) {
|
|
349
|
-
isPublic = false;
|
|
350
|
-
} else {
|
|
351
|
-
isPublic = await index.prompt({
|
|
352
|
-
type: 'confirm',
|
|
353
|
-
message: 'Will you publish this package to use in other projects?',
|
|
354
|
-
initial: true
|
|
355
|
-
});
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
return isPublic;
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
async function getReact(argv) {
|
|
362
|
-
let useReact;
|
|
363
|
-
|
|
364
|
-
if (argv['--react'] || argv['--yes']) {
|
|
365
|
-
useReact = true;
|
|
366
|
-
} else if (argv['--no-react']) {
|
|
367
|
-
useReact = false;
|
|
368
|
-
} else {
|
|
369
|
-
useReact = await index.prompt({
|
|
370
|
-
type: 'confirm',
|
|
371
|
-
message: 'Will this package depend on React?',
|
|
372
|
-
initial: true
|
|
373
|
-
});
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
return useReact;
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
function adjustPackageJson(packageJson, {
|
|
380
|
-
name,
|
|
381
|
-
react,
|
|
382
|
-
isPublic,
|
|
383
|
-
registry
|
|
384
|
-
}) {
|
|
385
|
-
packageJson.name = name;
|
|
386
|
-
const packageParts = name.split('/');
|
|
387
|
-
const scope = packageParts[0].startsWith('@') ? packageParts[0] : undefined;
|
|
388
|
-
const finalRegistry = registry ?? 'https://registry.npmjs.org';
|
|
389
|
-
|
|
390
|
-
if (scope) {
|
|
391
|
-
packageJson.publishConfig[`${scope}/registry`] = finalRegistry;
|
|
392
|
-
} else if (registry) {
|
|
393
|
-
packageJson.publishConfig.registry = finalRegistry;
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
if (isPublic) {
|
|
397
|
-
delete packageJson.private;
|
|
398
|
-
} else {
|
|
399
|
-
delete packageJson.publishConfig;
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
if (!react) {
|
|
403
|
-
delete packageJson.dependencies['@types/react'];
|
|
404
|
-
delete packageJson.devDependencies['react'];
|
|
405
|
-
delete packageJson.peerDependencies['react'];
|
|
406
|
-
delete packageJson.peerDependenciesMeta['react'];
|
|
407
|
-
packageJson.eslintConfig.extends = packageJson.eslintConfig.extends.filter(extend => !extend.includes('react'));
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
return packageJson;
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
function sortKeys(object) {
|
|
414
|
-
const newObject = {};
|
|
415
|
-
const sortedEntries = Object.entries(object).sort(([keyOne], [keyTwo]) => keyOne.localeCompare(keyTwo));
|
|
416
|
-
|
|
417
|
-
for (const [key, value] of sortedEntries) {
|
|
418
|
-
newObject[key] = value;
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
return newObject;
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
exports.createPackage = createPackage;
|