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