@quilted/create 0.1.19 → 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 +6 -0
- package/build/tsconfig.tsbuildinfo +1 -1
- package/build/typescript/package.d.ts +1 -1
- package/package.json +5 -3
- package/quilt.project.ts +19 -5
- package/source/create.ts +2 -2
- package/source/package.ts +1 -1
- package/templates/app-basic/quilt.project.ts +5 -5
- package/templates/app-basic/tsconfig.json +1 -1
- package/templates/app-single-file/quilt.project.ts +3 -4
- package/templates/app-single-file/tsconfig.json +1 -1
- package/templates/package/package.json +2 -2
- package/templates/package/quilt.project.ts +3 -4
- package/templates/package/tsconfig.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 -301
- 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 -425
- 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 -278
- 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 -402
- 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/app.cjs
DELETED
|
@@ -1,301 +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 createApp() {
|
|
35
|
-
const argv = getArgv();
|
|
36
|
-
|
|
37
|
-
if (argv['--help']) {
|
|
38
|
-
const additionalOptions = index.stripIndent`
|
|
39
|
-
${index.cyan_1(`--template`)}
|
|
40
|
-
The template to use for your new application. If you don’t specify a template,
|
|
41
|
-
this command will ask you for one instead. Must be one of the following:
|
|
42
|
-
|
|
43
|
-
- ${index.bold_1('basic')}, a web app with a minimal file structure
|
|
44
|
-
- ${index.bold_1('single-file')}, an entire web app in a single file
|
|
45
|
-
`;
|
|
46
|
-
index.printHelp({
|
|
47
|
-
kind: 'app',
|
|
48
|
-
options: additionalOptions,
|
|
49
|
-
packageManager: argv['--package-manager']?.toLowerCase()
|
|
50
|
-
});
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const inWorkspace = fs__namespace.existsSync('quilt.workspace.ts');
|
|
55
|
-
const name = await getName(argv, {
|
|
56
|
-
inWorkspace
|
|
57
|
-
});
|
|
58
|
-
const directory = await getDirectory(argv, {
|
|
59
|
-
name
|
|
60
|
-
});
|
|
61
|
-
const template = await getTemplate(argv);
|
|
62
|
-
const createAsMonorepo = !inWorkspace && (await index.getCreateAsMonorepo(argv));
|
|
63
|
-
const shouldInstall = await index.getShouldInstall(argv);
|
|
64
|
-
const packageManager$1 = await index.getPackageManager(argv);
|
|
65
|
-
const setupExtras = await index.getExtrasToSetup(argv, {
|
|
66
|
-
inWorkspace
|
|
67
|
-
});
|
|
68
|
-
const partOfMonorepo = inWorkspace || createAsMonorepo;
|
|
69
|
-
const appDirectory = createAsMonorepo ? path__namespace.join(directory, 'app') : directory;
|
|
70
|
-
|
|
71
|
-
if (fs__namespace.existsSync(directory)) {
|
|
72
|
-
await packageManager.emptyDirectory(directory);
|
|
73
|
-
|
|
74
|
-
if (appDirectory !== directory) {
|
|
75
|
-
fs__namespace.mkdirSync(appDirectory, {
|
|
76
|
-
recursive: true
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
} else {
|
|
80
|
-
fs__namespace.mkdirSync(appDirectory, {
|
|
81
|
-
recursive: true
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const rootDirectory = inWorkspace ? process.cwd() : directory;
|
|
86
|
-
const outputRoot = packageManager.createOutputTarget(rootDirectory);
|
|
87
|
-
const appTemplate = packageManager.loadTemplate(template === 'basic' ? 'app-basic' : 'app-single-file');
|
|
88
|
-
const workspaceTemplate = packageManager.loadTemplate('workspace'); // If we aren’t already in a workspace, copy the workspace files over, which
|
|
89
|
-
// are needed if we are making a monorepo or not.
|
|
90
|
-
|
|
91
|
-
if (!inWorkspace) {
|
|
92
|
-
await workspaceTemplate.copy(directory, file => {
|
|
93
|
-
// When this is a single project, we use the project’s Quilt configuration as the base.
|
|
94
|
-
if (file === 'quilt.workspace.ts') return createAsMonorepo; // We need to make some adjustments to the root package.json
|
|
95
|
-
|
|
96
|
-
return file !== 'package.json';
|
|
97
|
-
}); // If we are creating a monorepo, we need to add the root package.json and
|
|
98
|
-
// package manager workspace configuration.
|
|
99
|
-
|
|
100
|
-
if (createAsMonorepo) {
|
|
101
|
-
const workspacePackageJson = JSON.parse(await workspaceTemplate.read('package.json'));
|
|
102
|
-
workspacePackageJson.name = packageManager.toValidPackageName(name);
|
|
103
|
-
|
|
104
|
-
if (packageManager$1 === 'pnpm') {
|
|
105
|
-
await outputRoot.write('pnpm-workspace.yaml', await packageManager.format(`
|
|
106
|
-
packages:
|
|
107
|
-
- './packages/*'
|
|
108
|
-
`, {
|
|
109
|
-
as: 'yaml'
|
|
110
|
-
}));
|
|
111
|
-
} else {
|
|
112
|
-
workspacePackageJson.workspaces = ['packages/*'];
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
await outputRoot.write('package.json', await packageManager.format(JSON.stringify(workspacePackageJson), {
|
|
116
|
-
as: 'json-stringify'
|
|
117
|
-
}));
|
|
118
|
-
} else {
|
|
119
|
-
const [projectPackageJson, projectTSConfig, workspacePackageJson] = await Promise.all([appTemplate.read('package.json').then(content => JSON.parse(content)), appTemplate.read('tsconfig.json').then(content => JSON.parse(content)), workspaceTemplate.read('package.json').then(content => JSON.parse(content))]);
|
|
120
|
-
workspacePackageJson.name = packageManager.toValidPackageName(name);
|
|
121
|
-
workspacePackageJson.eslintConfig = projectPackageJson.eslintConfig;
|
|
122
|
-
workspacePackageJson.browserslist = projectPackageJson.browserslist;
|
|
123
|
-
let quiltProject = await appTemplate.read('quilt.project.ts');
|
|
124
|
-
quiltProject = quiltProject.replace('quiltApp', 'quiltWorkspace, quiltApp').replace('quiltApp(', 'quiltWorkspace(), quiltApp(');
|
|
125
|
-
await outputRoot.write('quilt.project.ts', await packageManager.format(quiltProject, {
|
|
126
|
-
as: 'typescript'
|
|
127
|
-
}));
|
|
128
|
-
await outputRoot.write('package.json', await packageManager.format(JSON.stringify(workspacePackageJson), {
|
|
129
|
-
as: 'json-stringify'
|
|
130
|
-
}));
|
|
131
|
-
await outputRoot.write('tsconfig.json', await packageManager.format(JSON.stringify(projectTSConfig), {
|
|
132
|
-
as: 'json'
|
|
133
|
-
}));
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
if (setupExtras.has('github')) {
|
|
137
|
-
await packageManager.loadTemplate('github').copy(directory);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
if (setupExtras.has('vscode')) {
|
|
141
|
-
await packageManager.loadTemplate('vscode').copy(directory);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
await appTemplate.copy(appDirectory, file => {
|
|
146
|
-
// If we are in a monorepo, we can use all the template files as they are
|
|
147
|
-
if (file === 'quilt.project.ts' || file === 'tsconfig.json') {
|
|
148
|
-
return partOfMonorepo;
|
|
149
|
-
} // We need to make some adjustments the project’s package.json
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
return file !== 'package.json';
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
if (partOfMonorepo) {
|
|
156
|
-
// Write the app’s package.json (the root one was already created)
|
|
157
|
-
const projectPackageJson = JSON.parse(await appTemplate.read('package.json'));
|
|
158
|
-
projectPackageJson.name = path__namespace.basename(appDirectory);
|
|
159
|
-
await outputRoot.write(path__namespace.join(appDirectory, 'package.json'), await packageManager.format(JSON.stringify(projectPackageJson), {
|
|
160
|
-
as: 'json-stringify'
|
|
161
|
-
}));
|
|
162
|
-
await Promise.all([packageManager.addToTsConfig(appDirectory, outputRoot), packageManager.addToPackageManagerWorkspaces(appDirectory, outputRoot, packageManager$1)]);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
if (shouldInstall) {
|
|
166
|
-
process.stdout.write('\nInstalling dependencies...\n'); // TODO: better loading, handle errors
|
|
167
|
-
|
|
168
|
-
child_process.execSync(`${packageManager$1} install`, {
|
|
169
|
-
cwd: rootDirectory
|
|
170
|
-
});
|
|
171
|
-
process.stdout.moveCursor(0, -1);
|
|
172
|
-
process.stdout.clearLine(1);
|
|
173
|
-
console.log('Installed dependencies.');
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
const commands = [];
|
|
177
|
-
|
|
178
|
-
if (!inWorkspace && directory !== process.cwd()) {
|
|
179
|
-
commands.push(`cd ${index.cyan_1(packageManager.relativeDirectoryForDisplay(path__namespace.relative(process.cwd(), directory)))} ${index.dim_1('# Move into your new app’s directory')}`);
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
if (!shouldInstall) {
|
|
183
|
-
commands.push(`pnpm install ${index.dim_1('# Install all your dependencies')}`);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
if (!inWorkspace) {
|
|
187
|
-
// TODO: change this condition to check if git was initialized already
|
|
188
|
-
commands.push(`git init && git add -A && git commit -m "Initial commit" ${index.dim_1('# Start your git history (optional)')}`);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
commands.push(`pnpm develop ${index.dim_1('# Start the development server')}`);
|
|
192
|
-
const whatsNext = index.stripIndent`
|
|
193
|
-
Your new app is ready to go! There’s just ${commands.length > 1 ? 'a few more steps' : 'one more step'} you’ll need to take
|
|
194
|
-
in order to start developing:
|
|
195
|
-
`;
|
|
196
|
-
console.log();
|
|
197
|
-
console.log(whatsNext);
|
|
198
|
-
console.log();
|
|
199
|
-
console.log(commands.map(command => ` ${command}`).join('\n'));
|
|
200
|
-
const followUp = index.stripIndent`
|
|
201
|
-
Quilt can also help you build, test, lint, and type-check your new application.
|
|
202
|
-
You can learn more about building apps with Quilt by reading the documentation:
|
|
203
|
-
${index.underline_1(index.magenta_1('https://github.com/lemonmade/quilt/tree/main/documentation'))}
|
|
204
|
-
|
|
205
|
-
Have fun! 🎉
|
|
206
|
-
`;
|
|
207
|
-
console.log();
|
|
208
|
-
console.log(followUp);
|
|
209
|
-
} // Argument handling
|
|
210
|
-
|
|
211
|
-
function getArgv() {
|
|
212
|
-
const argv = index.arg_1({
|
|
213
|
-
'--yes': Boolean,
|
|
214
|
-
'-y': '--yes',
|
|
215
|
-
'--name': String,
|
|
216
|
-
'--template': String,
|
|
217
|
-
'--directory': String,
|
|
218
|
-
'--install': Boolean,
|
|
219
|
-
'--no-install': Boolean,
|
|
220
|
-
'--monorepo': Boolean,
|
|
221
|
-
'--no-monorepo': Boolean,
|
|
222
|
-
'--package-manager': String,
|
|
223
|
-
'--extras': [String],
|
|
224
|
-
'--no-extras': Boolean,
|
|
225
|
-
'--help': Boolean,
|
|
226
|
-
'-h': '--help'
|
|
227
|
-
}, {
|
|
228
|
-
permissive: true
|
|
229
|
-
});
|
|
230
|
-
return argv;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
async function getName(argv, {
|
|
234
|
-
inWorkspace
|
|
235
|
-
}) {
|
|
236
|
-
let {
|
|
237
|
-
'--name': name
|
|
238
|
-
} = argv;
|
|
239
|
-
|
|
240
|
-
if (name == null) {
|
|
241
|
-
name = await index.prompt({
|
|
242
|
-
type: 'text',
|
|
243
|
-
message: 'What would you like to name your new app?',
|
|
244
|
-
initial: inWorkspace ? 'app' : 'my-quilt-app'
|
|
245
|
-
});
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
return name;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
async function getDirectory(argv, {
|
|
252
|
-
name
|
|
253
|
-
}) {
|
|
254
|
-
let directory = path__namespace.resolve(argv['--directory'] ?? packageManager.toValidPackageName(name));
|
|
255
|
-
|
|
256
|
-
while (!argv['--yes']) {
|
|
257
|
-
if (fs__namespace.existsSync(directory) && !(await packageManager.isEmpty(directory))) {
|
|
258
|
-
const relativeDirectory = path__namespace.relative(process.cwd(), directory);
|
|
259
|
-
const empty = await index.prompt({
|
|
260
|
-
type: 'confirm',
|
|
261
|
-
message: `Directory ${index.bold_1(packageManager.relativeDirectoryForDisplay(relativeDirectory))} is not empty, is it safe to empty it?`,
|
|
262
|
-
initial: true
|
|
263
|
-
});
|
|
264
|
-
if (empty) break;
|
|
265
|
-
const promptDirectory = await index.prompt({
|
|
266
|
-
type: 'text',
|
|
267
|
-
message: 'What directory do you want to create your new app in?'
|
|
268
|
-
});
|
|
269
|
-
directory = path__namespace.resolve(promptDirectory);
|
|
270
|
-
} else {
|
|
271
|
-
break;
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
return directory;
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
const VALID_TEMPLATES = new Set(['basic', 'single-file']);
|
|
279
|
-
|
|
280
|
-
async function getTemplate(argv) {
|
|
281
|
-
if (argv['--template'] && VALID_TEMPLATES.has(argv['--template'])) {
|
|
282
|
-
return argv['--template'];
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
const template = await index.prompt({
|
|
286
|
-
type: 'select',
|
|
287
|
-
message: 'What template would you like to use?',
|
|
288
|
-
hint: `Use ${index.bold_1('arrow keys')} to select, and ${index.bold_1('return')} to submit`,
|
|
289
|
-
choices: [{
|
|
290
|
-
title: `${index.bold_1('The basics')}, a web app with a minimal file structure`,
|
|
291
|
-
value: 'basic'
|
|
292
|
-
}, {
|
|
293
|
-
title: `${index.bold_1('Itty-bitty')}, an entire web app in a single file`,
|
|
294
|
-
value: 'single-file'
|
|
295
|
-
} // TODO: GraphQL API
|
|
296
|
-
]
|
|
297
|
-
});
|
|
298
|
-
return template;
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
exports.createApp = createApp;
|