@quilted/create 0.1.77 → 0.1.79

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 (112) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/build/cjs/app.cjs +20 -18
  3. package/build/cjs/module.cjs +15 -13
  4. package/build/cjs/package.cjs +10 -9
  5. package/build/cjs/service.cjs +8 -12
  6. package/build/esm/app.mjs +20 -18
  7. package/build/esm/module.mjs +15 -13
  8. package/build/esm/package.mjs +10 -9
  9. package/build/esm/service.mjs +8 -12
  10. package/build/esnext/app.esnext +20 -18
  11. package/build/esnext/module.esnext +15 -13
  12. package/build/esnext/package.esnext +10 -9
  13. package/build/tsconfig.tsbuildinfo +1 -1
  14. package/build/typescript/app.d.ts.map +1 -1
  15. package/build/typescript/module.d.ts.map +1 -1
  16. package/build/typescript/package.d.ts.map +1 -1
  17. package/build/typescript/service.d.ts.map +1 -1
  18. package/build/typescript/shared.d.ts +1 -1
  19. package/build/typescript/shared.d.ts.map +1 -1
  20. package/package.json +1 -1
  21. package/source/app.ts +35 -31
  22. package/source/module.ts +26 -22
  23. package/source/package.ts +20 -23
  24. package/source/service.ts +18 -23
  25. package/source/shared.ts +0 -2
  26. package/templates/app-basic/App.tsx +37 -13
  27. package/templates/app-basic/browser.tsx +2 -2
  28. package/templates/app-basic/features/start/Start/Start.tsx +5 -0
  29. package/templates/app-basic/features/start.ts +5 -0
  30. package/templates/app-basic/foundation/frame/Frame.module.css +14 -0
  31. package/templates/app-basic/foundation/frame/Frame.tsx +7 -0
  32. package/templates/app-basic/foundation/frame.ts +1 -0
  33. package/templates/app-basic/foundation/{Head → html}/Head.test.tsx +4 -4
  34. package/templates/app-basic/foundation/html.ts +1 -0
  35. package/templates/{app-trpc/foundation/Http/Http.test.tsx → app-basic/foundation/http/Headers.test.tsx} +8 -8
  36. package/templates/app-basic/foundation/{Http/Http.tsx → http/Headers.tsx} +3 -3
  37. package/templates/app-basic/foundation/http.ts +1 -0
  38. package/templates/app-basic/server.tsx +18 -15
  39. package/templates/app-basic/shared/context.ts +1 -6
  40. package/templates/app-basic/tests/render/render.tsx +12 -12
  41. package/templates/app-basic/tests/render/types.ts +3 -5
  42. package/templates/app-basic/tests/render.ts +2 -2
  43. package/templates/app-empty/App.tsx +1 -1
  44. package/templates/app-empty/browser.tsx +1 -1
  45. package/templates/app-empty/server.tsx +18 -14
  46. package/templates/app-graphql/App.tsx +36 -26
  47. package/templates/app-graphql/browser.tsx +1 -1
  48. package/templates/app-graphql/features/{Start → start/Start}/Start.test.tsx +3 -7
  49. package/templates/app-graphql/features/start/Start/Start.tsx +14 -0
  50. package/templates/app-graphql/features/start.ts +5 -0
  51. package/templates/app-graphql/foundation/frame/Frame.module.css +14 -0
  52. package/templates/app-graphql/foundation/frame/Frame.tsx +7 -0
  53. package/templates/app-graphql/foundation/frame.ts +1 -0
  54. package/templates/{app-trpc/foundation/Head → app-graphql/foundation/html}/Head.test.tsx +4 -4
  55. package/templates/app-graphql/foundation/html.ts +1 -0
  56. package/templates/{app-basic/foundation/Http/Http.test.tsx → app-graphql/foundation/http/Headers.test.tsx} +8 -8
  57. package/templates/app-graphql/foundation/{Http/Http.tsx → http/Headers.tsx} +3 -3
  58. package/templates/app-graphql/foundation/http.ts +1 -0
  59. package/templates/app-graphql/server/graphql.ts +1 -2
  60. package/templates/app-graphql/server.tsx +36 -33
  61. package/templates/app-graphql/shared/context.ts +1 -6
  62. package/templates/app-graphql/tests/graphql.ts +3 -4
  63. package/templates/app-graphql/tests/render/render.tsx +16 -15
  64. package/templates/app-graphql/tests/render/types.ts +3 -5
  65. package/templates/app-graphql/tests/render.ts +3 -3
  66. package/templates/app-trpc/App.tsx +39 -33
  67. package/templates/app-trpc/browser.tsx +1 -1
  68. package/templates/app-trpc/features/{Start → start/Start}/Start.test.tsx +2 -2
  69. package/templates/app-trpc/features/start/Start/Start.tsx +9 -0
  70. package/templates/app-trpc/features/start.ts +5 -0
  71. package/templates/app-trpc/foundation/frame/Frame.module.css +14 -0
  72. package/templates/app-trpc/foundation/frame/Frame.tsx +7 -0
  73. package/templates/app-trpc/foundation/frame.ts +1 -0
  74. package/templates/{app-graphql/foundation/Head → app-trpc/foundation/html}/Head.test.tsx +4 -4
  75. package/templates/app-trpc/foundation/html.ts +1 -0
  76. package/templates/{app-graphql/foundation/Http/Http.test.tsx → app-trpc/foundation/http/Headers.test.tsx} +8 -8
  77. package/templates/app-trpc/foundation/{Http/Http.tsx → http/Headers.tsx} +3 -3
  78. package/templates/app-trpc/foundation/http.ts +1 -0
  79. package/templates/app-trpc/server.tsx +1 -1
  80. package/templates/app-trpc/shared/context.ts +1 -6
  81. package/templates/app-trpc/tests/render/render.tsx +17 -16
  82. package/templates/service-basic/service.ts +2 -2
  83. package/templates/app-basic/features/Start/Start.tsx +0 -12
  84. package/templates/app-basic/features/Start.tsx +0 -3
  85. package/templates/app-basic/foundation/Head.tsx +0 -1
  86. package/templates/app-basic/foundation/Http.tsx +0 -1
  87. package/templates/app-basic/foundation/Metrics/Metrics.tsx +0 -23
  88. package/templates/app-basic/foundation/Metrics.tsx +0 -1
  89. package/templates/app-graphql/features/Start/Start.tsx +0 -20
  90. package/templates/app-graphql/features/Start.tsx +0 -3
  91. package/templates/app-graphql/foundation/Head.tsx +0 -1
  92. package/templates/app-graphql/foundation/Http.tsx +0 -1
  93. package/templates/app-graphql/foundation/Metrics/Metrics.tsx +0 -23
  94. package/templates/app-graphql/foundation/Metrics.tsx +0 -1
  95. package/templates/app-single-file/App.tsx +0 -199
  96. package/templates/app-single-file/package.json +0 -35
  97. package/templates/app-single-file/quilt.project.ts +0 -5
  98. package/templates/app-single-file/tsconfig.json +0 -9
  99. package/templates/app-trpc/features/Start/Start.tsx +0 -16
  100. package/templates/app-trpc/features/Start.tsx +0 -3
  101. package/templates/app-trpc/foundation/Head.tsx +0 -1
  102. package/templates/app-trpc/foundation/Http.tsx +0 -1
  103. package/templates/app-trpc/foundation/Metrics/Metrics.tsx +0 -23
  104. package/templates/app-trpc/foundation/Metrics.tsx +0 -1
  105. /package/templates/app-basic/features/{Start → start/Start}/Start.module.css +0 -0
  106. /package/templates/app-basic/features/{Start → start/Start}/Start.test.tsx +0 -0
  107. /package/templates/app-basic/foundation/{Head → html}/Head.tsx +0 -0
  108. /package/templates/app-graphql/features/{Start → start/Start}/Start.module.css +0 -0
  109. /package/templates/app-graphql/features/{Start → start/Start}/StartQuery.graphql +0 -0
  110. /package/templates/app-graphql/foundation/{Head → html}/Head.tsx +0 -0
  111. /package/templates/app-trpc/features/{Start → start/Start}/Start.module.css +0 -0
  112. /package/templates/app-trpc/foundation/{Head → html}/Head.tsx +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @quilted/create
2
2
 
3
+ ## 0.1.79
4
+
5
+ ### Patch Changes
6
+
7
+ - [#612](https://github.com/lemonmade/quilt/pull/612) [`bc849bc7`](https://github.com/lemonmade/quilt/commit/bc849bc740318936656162fde851b784ed6ef78f) Thanks [@lemonmade](https://github.com/lemonmade)! - Simplify app template APIs
8
+
9
+ ## 0.1.78
10
+
11
+ ### Patch Changes
12
+
13
+ - [`e8626447`](https://github.com/lemonmade/quilt/commit/e86264471e99107b6a393fe09237800d2ca6fe1c) Thanks [@lemonmade](https://github.com/lemonmade)! - Another attempted create() fix
14
+
3
15
  ## 0.1.77
4
16
 
5
17
  ### Patch Changes
package/build/cjs/app.cjs CHANGED
@@ -54,9 +54,10 @@ async function createApp() {
54
54
  The template to use for your new application. If you don’t specify a template,
55
55
  this command will ask you for one instead. Must be one of the following:
56
56
 
57
+ - ${index.bold('empty')}, a basic React app without any extra runtime dependencies
57
58
  - ${index.bold('basic')}, a web app with a minimal file structure
58
- - ${index.bold('single-file')}, an entire web app in a single file
59
- - ${index.bold('empty')}, a basic React app without any extra runtime dependencies
59
+ - ${index.bold('graphql')}, a web app with a GraphQL API, fetched using @tanstack/react-query
60
+ - ${index.bold('trpc')}, a web app with a tRPC API, fetched using @tanstack/react-query
60
61
  `;
61
62
  help.printHelp({
62
63
  kind: 'app',
@@ -75,7 +76,7 @@ async function createApp() {
75
76
  const template = await getTemplate(argv);
76
77
  const createAsMonorepo = !inWorkspace && (await prompts.getCreateAsMonorepo(argv, {
77
78
  type: 'app',
78
- default: template !== 'single-file'
79
+ default: true
79
80
  }));
80
81
  const setupExtras = await prompts.getExtrasToSetup(argv, {
81
82
  inWorkspace
@@ -139,11 +140,6 @@ async function createApp() {
139
140
  const combinedPackageJson = shared.mergeWorkspaceAndProjectPackageJsons(projectPackageJson, workspacePackageJson);
140
141
  combinedPackageJson.name = shared.toValidPackageName(name);
141
142
  delete combinedPackageJson.workspaces;
142
- let quiltProject = await appTemplate.read('quilt.project.ts');
143
- quiltProject = quiltProject.replace('quiltApp', 'quiltWorkspace, quiltApp').replace('quiltApp(', 'quiltWorkspace(), quiltApp(');
144
- await outputRoot.write('quilt.project.ts', await shared.format(quiltProject, {
145
- as: 'typescript'
146
- }));
147
143
  await outputRoot.write('package.json', await shared.format(JSON.stringify(combinedPackageJson), {
148
144
  as: 'json-stringify'
149
145
  }));
@@ -160,13 +156,22 @@ async function createApp() {
160
156
  }
161
157
  await appTemplate.copy(appDirectory, file => {
162
158
  // If we are in a monorepo, we can use all the template files as they are
163
- if (file === 'quilt.project.ts' || file === 'tsconfig.json') {
159
+ if (file === 'tsconfig.json') {
164
160
  return partOfMonorepo;
165
161
  }
166
162
 
167
- // We need to make some adjustments the project’s package.json
168
- return file !== 'package.json';
163
+ // We need to make some adjustments the project’s package.json and
164
+ // quilt config file
165
+ if (file === 'package.json' || file === 'quilt.project.ts') return false;
166
+ return true;
169
167
  });
168
+ let quiltProject = await appTemplate.read('quilt.project.ts');
169
+ if (!partOfMonorepo) {
170
+ quiltProject = quiltProject.replace('quiltApp', 'quiltWorkspace, quiltApp').replace('quiltApp(', 'quiltWorkspace(), quiltApp(');
171
+ }
172
+ await outputRoot.write(path__namespace.join(appDirectory, 'quilt.project.ts'), await shared.format(quiltProject, {
173
+ as: 'typescript'
174
+ }));
170
175
  if (template === 'graphql' && !inWorkspace) {
171
176
  const relativeFromRootToAppPath = filePath => path__namespace.relative(outputRoot.root, path__namespace.join(appDirectory, filePath));
172
177
  await outputRoot.write('graphql.config.ts', stripIndent["default"]`
@@ -288,7 +293,7 @@ async function getDirectory(argv, {
288
293
  }
289
294
  return directory;
290
295
  }
291
- const VALID_TEMPLATES = new Set(['basic', 'graphql', 'trpc', 'single-file', 'empty']);
296
+ const VALID_TEMPLATES = new Set(['basic', 'graphql', 'trpc', 'empty']);
292
297
  async function getTemplate(argv) {
293
298
  if (argv['--template'] && VALID_TEMPLATES.has(argv['--template'])) {
294
299
  return argv['--template'];
@@ -298,14 +303,11 @@ async function getTemplate(argv) {
298
303
  message: 'What template would you like to use?',
299
304
  hint: `Use ${index.bold('arrow keys')} to select, and ${index.bold('return')} to submit`,
300
305
  choices: [{
301
- title: `${index.bold('The basics')}, a web app with a minimal file structure`,
302
- value: 'basic'
303
- }, {
304
- title: `${index.bold('Itty-bitty')}, an entire web app in a single file`,
305
- value: 'single-file'
306
- }, {
307
306
  title: `${index.bold('Empty')}, a basic React app without any extra runtime dependencies`,
308
307
  value: 'empty'
308
+ }, {
309
+ title: `${index.bold('The basics')}, a web app with a minimal file structure`,
310
+ value: 'basic'
309
311
  }, {
310
312
  title: `${index.bold('GraphQL')}, a web app with a GraphQL API, fetched using @tanstack/react-query`,
311
313
  value: 'graphql'
@@ -134,14 +134,6 @@ async function createModule() {
134
134
  react: useReact
135
135
  });
136
136
  delete combinedPackageJson.workspaces;
137
- let quiltProject = await moduleTemplate.read('quilt.project.ts');
138
- quiltProject = quiltProject.replace('quiltModule', 'quiltWorkspace, quiltModule').replace('quiltModule(', 'quiltWorkspace(), quiltModule(');
139
- if (!useReact) {
140
- quiltProject = quiltProject.replace('quiltPackage()', 'quiltPackage({react: false})');
141
- }
142
- await outputRoot.write('quilt.project.ts', await shared.format(quiltProject, {
143
- as: 'typescript'
144
- }));
145
137
  await outputRoot.write('package.json', await shared.format(JSON.stringify(combinedPackageJson), {
146
138
  as: 'json-stringify'
147
139
  }));
@@ -163,13 +155,23 @@ async function createModule() {
163
155
  }
164
156
 
165
157
  // We will adjust the entry file
166
- if (file === 'module.ts') {
167
- return false;
168
- }
158
+ if (file === 'module.ts') return false;
169
159
 
170
- // We need to make some adjustments the project’s package.json
171
- return file !== 'package.json';
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;
172
164
  });
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
+ }));
173
175
  await outputRoot.write(path__namespace.join(moduleDirectory, entry), await moduleTemplate.read('module.ts'));
174
176
  if (partOfMonorepo) {
175
177
  // Write the app’s package.json (the root one was already created)
@@ -119,10 +119,6 @@ async function createProject() {
119
119
  const outputRoot = shared.createOutputTarget(rootDirectory);
120
120
  const packageTemplate = shared.loadTemplate('package');
121
121
  const workspaceTemplate = shared.loadTemplate('workspace');
122
- let quiltProject = await packageTemplate.read('quilt.project.ts');
123
- if (!useReact) {
124
- quiltProject = quiltProject.replace('quiltPackage()', 'quiltPackage({react: false})');
125
- }
126
122
 
127
123
  // If we aren’t already in a workspace, copy the workspace files over, which
128
124
  // are needed if we are making a monorepo or not.
@@ -166,10 +162,6 @@ async function createProject() {
166
162
  isPublic,
167
163
  registry: args['--registry']
168
164
  });
169
- quiltProject = quiltProject.replace('quiltPackage', 'quiltWorkspace, quiltPackage').replace('quiltPackage(', 'quiltWorkspace(), quiltPackage(');
170
- await outputRoot.write('quilt.project.ts', await shared.format(quiltProject, {
171
- as: 'typescript'
172
- }));
173
165
  await outputRoot.write('package.json', await shared.format(JSON.stringify(mergedPackageJson), {
174
166
  as: 'json-stringify'
175
167
  }));
@@ -193,6 +185,16 @@ async function createProject() {
193
185
  // We need to make some adjustments the project’s package.json, README, and Quilt config
194
186
  return file !== 'package.json' && file !== 'quilt.project.ts' && file !== 'README.md';
195
187
  });
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
+ }));
196
198
  await outputRoot.write(path__namespace.join(packageDirectory, 'README.md'), (await packageTemplate.read('README.md')).replaceAll('{{name}}', shared.toValidPackageName(name)));
197
199
  if (partOfMonorepo) {
198
200
  // Write the package’s package.json (the root one was already created)
@@ -227,7 +229,6 @@ async function createProject() {
227
229
  await outputRoot.write(path__namespace.join(packageDirectory, 'package.json'), await shared.format(JSON.stringify(projectPackageJson), {
228
230
  as: 'json-stringify'
229
231
  }));
230
- await outputRoot.write(path__namespace.join(packageDirectory, 'quilt.project.ts'), quiltProject);
231
232
  await Promise.all([tsconfig.addToTsConfig(packageDirectory, outputRoot), packageManager.addToPackageManagerWorkspaces(packageDirectory, outputRoot, packageManager$1.type)]);
232
233
  }
233
234
  if (shouldInstall) {
@@ -132,11 +132,6 @@ async function createService() {
132
132
  entry
133
133
  });
134
134
  delete combinedPackageJson.workspaces;
135
- let quiltProject = await serviceTemplate.read('quilt.project.ts');
136
- quiltProject = quiltProject.replace('quiltService', 'quiltWorkspace, quiltService').replace('quiltService(', 'quiltWorkspace(), quiltService(').replace('service.ts', entry.replace(/^\.[/]/, ''));
137
- await outputRoot.write('quilt.project.ts', await shared.format(quiltProject, {
138
- as: 'typescript'
139
- }));
140
135
  await outputRoot.write('package.json', await shared.format(JSON.stringify(combinedPackageJson), {
141
136
  as: 'json-stringify'
142
137
  }));
@@ -165,6 +160,14 @@ async function createService() {
165
160
  // We need to make some adjustments the project’s package.json
166
161
  return file !== 'package.json';
167
162
  });
163
+ let quiltProject = await serviceTemplate.read('quilt.project.ts');
164
+ if (!partOfMonorepo) {
165
+ quiltProject = quiltProject.replace('quiltService', 'quiltWorkspace, quiltService').replace('quiltService(', 'quiltWorkspace(), quiltService(');
166
+ }
167
+ quiltProject = quiltProject.replace('service.ts', entry.replace(/^\.[/]/, ''));
168
+ await outputRoot.write(path__namespace.join(serviceDirectory, 'quilt.project.ts'), await shared.format(quiltProject, {
169
+ as: 'typescript'
170
+ }));
168
171
  await outputRoot.write(path__namespace.join(serviceDirectory, entry), await serviceTemplate.read('service.ts'));
169
172
  if (partOfMonorepo) {
170
173
  // Write the app’s package.json (the root one was already created)
@@ -177,13 +180,6 @@ async function createService() {
177
180
  as: 'json-stringify'
178
181
  }));
179
182
  await Promise.all([tsconfig.addToTsConfig(serviceDirectory, outputRoot), packageManager.addToPackageManagerWorkspaces(serviceDirectory, outputRoot, packageManager$1.type)]);
180
- } else {
181
- // We already wrote a root `quilt.project.ts` file if the project is a monorepo
182
- let quiltProject = await serviceTemplate.read('quilt.project.ts');
183
- quiltProject = quiltProject.replace('service.ts', entry.replace(/^\.[/]/, ''));
184
- await outputRoot.write(path__namespace.join(serviceDirectory, 'quilt.project.ts'), await shared.format(quiltProject, {
185
- as: 'typescript'
186
- }));
187
183
  }
188
184
  if (shouldInstall) {
189
185
  console.log();
package/build/esm/app.mjs CHANGED
@@ -32,9 +32,10 @@ async function createApp() {
32
32
  The template to use for your new application. If you don’t specify a template,
33
33
  this command will ask you for one instead. Must be one of the following:
34
34
 
35
+ - ${bold_1('empty')}, a basic React app without any extra runtime dependencies
35
36
  - ${bold_1('basic')}, a web app with a minimal file structure
36
- - ${bold_1('single-file')}, an entire web app in a single file
37
- - ${bold_1('empty')}, a basic React app without any extra runtime dependencies
37
+ - ${bold_1('graphql')}, a web app with a GraphQL API, fetched using @tanstack/react-query
38
+ - ${bold_1('trpc')}, a web app with a tRPC API, fetched using @tanstack/react-query
38
39
  `;
39
40
  printHelp({
40
41
  kind: 'app',
@@ -53,7 +54,7 @@ async function createApp() {
53
54
  const template = await getTemplate(argv);
54
55
  const createAsMonorepo = !inWorkspace && (await getCreateAsMonorepo(argv, {
55
56
  type: 'app',
56
- default: template !== 'single-file'
57
+ default: true
57
58
  }));
58
59
  const setupExtras = await getExtrasToSetup(argv, {
59
60
  inWorkspace
@@ -117,11 +118,6 @@ async function createApp() {
117
118
  const combinedPackageJson = mergeWorkspaceAndProjectPackageJsons(projectPackageJson, workspacePackageJson);
118
119
  combinedPackageJson.name = toValidPackageName(name);
119
120
  delete combinedPackageJson.workspaces;
120
- let quiltProject = await appTemplate.read('quilt.project.ts');
121
- quiltProject = quiltProject.replace('quiltApp', 'quiltWorkspace, quiltApp').replace('quiltApp(', 'quiltWorkspace(), quiltApp(');
122
- await outputRoot.write('quilt.project.ts', await format(quiltProject, {
123
- as: 'typescript'
124
- }));
125
121
  await outputRoot.write('package.json', await format(JSON.stringify(combinedPackageJson), {
126
122
  as: 'json-stringify'
127
123
  }));
@@ -138,13 +134,22 @@ async function createApp() {
138
134
  }
139
135
  await appTemplate.copy(appDirectory, file => {
140
136
  // If we are in a monorepo, we can use all the template files as they are
141
- if (file === 'quilt.project.ts' || file === 'tsconfig.json') {
137
+ if (file === 'tsconfig.json') {
142
138
  return partOfMonorepo;
143
139
  }
144
140
 
145
- // We need to make some adjustments the project’s package.json
146
- return file !== 'package.json';
141
+ // We need to make some adjustments the project’s package.json and
142
+ // quilt config file
143
+ if (file === 'package.json' || file === 'quilt.project.ts') return false;
144
+ return true;
147
145
  });
146
+ let quiltProject = await appTemplate.read('quilt.project.ts');
147
+ if (!partOfMonorepo) {
148
+ quiltProject = quiltProject.replace('quiltApp', 'quiltWorkspace, quiltApp').replace('quiltApp(', 'quiltWorkspace(), quiltApp(');
149
+ }
150
+ await outputRoot.write(path.join(appDirectory, 'quilt.project.ts'), await format(quiltProject, {
151
+ as: 'typescript'
152
+ }));
148
153
  if (template === 'graphql' && !inWorkspace) {
149
154
  const relativeFromRootToAppPath = filePath => path.relative(outputRoot.root, path.join(appDirectory, filePath));
150
155
  await outputRoot.write('graphql.config.ts', stripIndent`
@@ -266,7 +271,7 @@ async function getDirectory(argv, {
266
271
  }
267
272
  return directory;
268
273
  }
269
- const VALID_TEMPLATES = new Set(['basic', 'graphql', 'trpc', 'single-file', 'empty']);
274
+ const VALID_TEMPLATES = new Set(['basic', 'graphql', 'trpc', 'empty']);
270
275
  async function getTemplate(argv) {
271
276
  if (argv['--template'] && VALID_TEMPLATES.has(argv['--template'])) {
272
277
  return argv['--template'];
@@ -276,14 +281,11 @@ async function getTemplate(argv) {
276
281
  message: 'What template would you like to use?',
277
282
  hint: `Use ${bold_1('arrow keys')} to select, and ${bold_1('return')} to submit`,
278
283
  choices: [{
279
- title: `${bold_1('The basics')}, a web app with a minimal file structure`,
280
- value: 'basic'
281
- }, {
282
- title: `${bold_1('Itty-bitty')}, an entire web app in a single file`,
283
- value: 'single-file'
284
- }, {
285
284
  title: `${bold_1('Empty')}, a basic React app without any extra runtime dependencies`,
286
285
  value: 'empty'
286
+ }, {
287
+ title: `${bold_1('The basics')}, a web app with a minimal file structure`,
288
+ value: 'basic'
287
289
  }, {
288
290
  title: `${bold_1('GraphQL')}, a web app with a GraphQL API, fetched using @tanstack/react-query`,
289
291
  value: 'graphql'
@@ -112,14 +112,6 @@ async function createModule() {
112
112
  react: useReact
113
113
  });
114
114
  delete combinedPackageJson.workspaces;
115
- let quiltProject = await moduleTemplate.read('quilt.project.ts');
116
- quiltProject = quiltProject.replace('quiltModule', 'quiltWorkspace, quiltModule').replace('quiltModule(', 'quiltWorkspace(), quiltModule(');
117
- if (!useReact) {
118
- quiltProject = quiltProject.replace('quiltPackage()', 'quiltPackage({react: false})');
119
- }
120
- await outputRoot.write('quilt.project.ts', await format(quiltProject, {
121
- as: 'typescript'
122
- }));
123
115
  await outputRoot.write('package.json', await format(JSON.stringify(combinedPackageJson), {
124
116
  as: 'json-stringify'
125
117
  }));
@@ -141,13 +133,23 @@ async function createModule() {
141
133
  }
142
134
 
143
135
  // We will adjust the entry file
144
- if (file === 'module.ts') {
145
- return false;
146
- }
136
+ if (file === 'module.ts') return false;
147
137
 
148
- // We need to make some adjustments the project’s package.json
149
- return file !== 'package.json';
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;
150
142
  });
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
+ }));
151
153
  await outputRoot.write(path.join(moduleDirectory, entry), await moduleTemplate.read('module.ts'));
152
154
  if (partOfMonorepo) {
153
155
  // Write the app’s package.json (the root one was already created)
@@ -97,10 +97,6 @@ async function createProject() {
97
97
  const outputRoot = createOutputTarget(rootDirectory);
98
98
  const packageTemplate = loadTemplate('package');
99
99
  const workspaceTemplate = loadTemplate('workspace');
100
- let quiltProject = await packageTemplate.read('quilt.project.ts');
101
- if (!useReact) {
102
- quiltProject = quiltProject.replace('quiltPackage()', 'quiltPackage({react: false})');
103
- }
104
100
 
105
101
  // If we aren’t already in a workspace, copy the workspace files over, which
106
102
  // are needed if we are making a monorepo or not.
@@ -144,10 +140,6 @@ async function createProject() {
144
140
  isPublic,
145
141
  registry: args['--registry']
146
142
  });
147
- quiltProject = quiltProject.replace('quiltPackage', 'quiltWorkspace, quiltPackage').replace('quiltPackage(', 'quiltWorkspace(), quiltPackage(');
148
- await outputRoot.write('quilt.project.ts', await format(quiltProject, {
149
- as: 'typescript'
150
- }));
151
143
  await outputRoot.write('package.json', await format(JSON.stringify(mergedPackageJson), {
152
144
  as: 'json-stringify'
153
145
  }));
@@ -171,6 +163,16 @@ async function createProject() {
171
163
  // We need to make some adjustments the project’s package.json, README, and Quilt config
172
164
  return file !== 'package.json' && file !== 'quilt.project.ts' && file !== 'README.md';
173
165
  });
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
+ }));
174
176
  await outputRoot.write(path.join(packageDirectory, 'README.md'), (await packageTemplate.read('README.md')).replaceAll('{{name}}', toValidPackageName(name)));
175
177
  if (partOfMonorepo) {
176
178
  // Write the package’s package.json (the root one was already created)
@@ -205,7 +207,6 @@ async function createProject() {
205
207
  await outputRoot.write(path.join(packageDirectory, 'package.json'), await format(JSON.stringify(projectPackageJson), {
206
208
  as: 'json-stringify'
207
209
  }));
208
- await outputRoot.write(path.join(packageDirectory, 'quilt.project.ts'), quiltProject);
209
210
  await Promise.all([addToTsConfig(packageDirectory, outputRoot), addToPackageManagerWorkspaces(packageDirectory, outputRoot, packageManager.type)]);
210
211
  }
211
212
  if (shouldInstall) {
@@ -110,11 +110,6 @@ async function createService() {
110
110
  entry
111
111
  });
112
112
  delete combinedPackageJson.workspaces;
113
- let quiltProject = await serviceTemplate.read('quilt.project.ts');
114
- quiltProject = quiltProject.replace('quiltService', 'quiltWorkspace, quiltService').replace('quiltService(', 'quiltWorkspace(), quiltService(').replace('service.ts', entry.replace(/^\.[/]/, ''));
115
- await outputRoot.write('quilt.project.ts', await format(quiltProject, {
116
- as: 'typescript'
117
- }));
118
113
  await outputRoot.write('package.json', await format(JSON.stringify(combinedPackageJson), {
119
114
  as: 'json-stringify'
120
115
  }));
@@ -143,6 +138,14 @@ async function createService() {
143
138
  // We need to make some adjustments the project’s package.json
144
139
  return file !== 'package.json';
145
140
  });
141
+ let quiltProject = await serviceTemplate.read('quilt.project.ts');
142
+ if (!partOfMonorepo) {
143
+ quiltProject = quiltProject.replace('quiltService', 'quiltWorkspace, quiltService').replace('quiltService(', 'quiltWorkspace(), quiltService(');
144
+ }
145
+ quiltProject = quiltProject.replace('service.ts', entry.replace(/^\.[/]/, ''));
146
+ await outputRoot.write(path.join(serviceDirectory, 'quilt.project.ts'), await format(quiltProject, {
147
+ as: 'typescript'
148
+ }));
146
149
  await outputRoot.write(path.join(serviceDirectory, entry), await serviceTemplate.read('service.ts'));
147
150
  if (partOfMonorepo) {
148
151
  // Write the app’s package.json (the root one was already created)
@@ -155,13 +158,6 @@ async function createService() {
155
158
  as: 'json-stringify'
156
159
  }));
157
160
  await Promise.all([addToTsConfig(serviceDirectory, outputRoot), addToPackageManagerWorkspaces(serviceDirectory, outputRoot, packageManager.type)]);
158
- } else {
159
- // We already wrote a root `quilt.project.ts` file if the project is a monorepo
160
- let quiltProject = await serviceTemplate.read('quilt.project.ts');
161
- quiltProject = quiltProject.replace('service.ts', entry.replace(/^\.[/]/, ''));
162
- await outputRoot.write(path.join(serviceDirectory, 'quilt.project.ts'), await format(quiltProject, {
163
- as: 'typescript'
164
- }));
165
161
  }
166
162
  if (shouldInstall) {
167
163
  console.log();
@@ -32,9 +32,10 @@ async function createApp() {
32
32
  The template to use for your new application. If you don’t specify a template,
33
33
  this command will ask you for one instead. Must be one of the following:
34
34
 
35
+ - ${bold_1('empty')}, a basic React app without any extra runtime dependencies
35
36
  - ${bold_1('basic')}, a web app with a minimal file structure
36
- - ${bold_1('single-file')}, an entire web app in a single file
37
- - ${bold_1('empty')}, a basic React app without any extra runtime dependencies
37
+ - ${bold_1('graphql')}, a web app with a GraphQL API, fetched using @tanstack/react-query
38
+ - ${bold_1('trpc')}, a web app with a tRPC API, fetched using @tanstack/react-query
38
39
  `;
39
40
  printHelp({
40
41
  kind: 'app',
@@ -53,7 +54,7 @@ async function createApp() {
53
54
  const template = await getTemplate(argv);
54
55
  const createAsMonorepo = !inWorkspace && (await getCreateAsMonorepo(argv, {
55
56
  type: 'app',
56
- default: template !== 'single-file'
57
+ default: true
57
58
  }));
58
59
  const setupExtras = await getExtrasToSetup(argv, {
59
60
  inWorkspace
@@ -117,11 +118,6 @@ async function createApp() {
117
118
  const combinedPackageJson = mergeWorkspaceAndProjectPackageJsons(projectPackageJson, workspacePackageJson);
118
119
  combinedPackageJson.name = toValidPackageName(name);
119
120
  delete combinedPackageJson.workspaces;
120
- let quiltProject = await appTemplate.read('quilt.project.ts');
121
- quiltProject = quiltProject.replace('quiltApp', 'quiltWorkspace, quiltApp').replace('quiltApp(', 'quiltWorkspace(), quiltApp(');
122
- await outputRoot.write('quilt.project.ts', await format(quiltProject, {
123
- as: 'typescript'
124
- }));
125
121
  await outputRoot.write('package.json', await format(JSON.stringify(combinedPackageJson), {
126
122
  as: 'json-stringify'
127
123
  }));
@@ -138,13 +134,22 @@ async function createApp() {
138
134
  }
139
135
  await appTemplate.copy(appDirectory, file => {
140
136
  // If we are in a monorepo, we can use all the template files as they are
141
- if (file === 'quilt.project.ts' || file === 'tsconfig.json') {
137
+ if (file === 'tsconfig.json') {
142
138
  return partOfMonorepo;
143
139
  }
144
140
 
145
- // We need to make some adjustments the project’s package.json
146
- return file !== 'package.json';
141
+ // We need to make some adjustments the project’s package.json and
142
+ // quilt config file
143
+ if (file === 'package.json' || file === 'quilt.project.ts') return false;
144
+ return true;
147
145
  });
146
+ let quiltProject = await appTemplate.read('quilt.project.ts');
147
+ if (!partOfMonorepo) {
148
+ quiltProject = quiltProject.replace('quiltApp', 'quiltWorkspace, quiltApp').replace('quiltApp(', 'quiltWorkspace(), quiltApp(');
149
+ }
150
+ await outputRoot.write(path.join(appDirectory, 'quilt.project.ts'), await format(quiltProject, {
151
+ as: 'typescript'
152
+ }));
148
153
  if (template === 'graphql' && !inWorkspace) {
149
154
  const relativeFromRootToAppPath = filePath => path.relative(outputRoot.root, path.join(appDirectory, filePath));
150
155
  await outputRoot.write('graphql.config.ts', stripIndent`
@@ -266,7 +271,7 @@ async function getDirectory(argv, {
266
271
  }
267
272
  return directory;
268
273
  }
269
- const VALID_TEMPLATES = new Set(['basic', 'graphql', 'trpc', 'single-file', 'empty']);
274
+ const VALID_TEMPLATES = new Set(['basic', 'graphql', 'trpc', 'empty']);
270
275
  async function getTemplate(argv) {
271
276
  if (argv['--template'] && VALID_TEMPLATES.has(argv['--template'])) {
272
277
  return argv['--template'];
@@ -276,14 +281,11 @@ async function getTemplate(argv) {
276
281
  message: 'What template would you like to use?',
277
282
  hint: `Use ${bold_1('arrow keys')} to select, and ${bold_1('return')} to submit`,
278
283
  choices: [{
279
- title: `${bold_1('The basics')}, a web app with a minimal file structure`,
280
- value: 'basic'
281
- }, {
282
- title: `${bold_1('Itty-bitty')}, an entire web app in a single file`,
283
- value: 'single-file'
284
- }, {
285
284
  title: `${bold_1('Empty')}, a basic React app without any extra runtime dependencies`,
286
285
  value: 'empty'
286
+ }, {
287
+ title: `${bold_1('The basics')}, a web app with a minimal file structure`,
288
+ value: 'basic'
287
289
  }, {
288
290
  title: `${bold_1('GraphQL')}, a web app with a GraphQL API, fetched using @tanstack/react-query`,
289
291
  value: 'graphql'
@@ -112,14 +112,6 @@ async function createModule() {
112
112
  react: useReact
113
113
  });
114
114
  delete combinedPackageJson.workspaces;
115
- let quiltProject = await moduleTemplate.read('quilt.project.ts');
116
- quiltProject = quiltProject.replace('quiltModule', 'quiltWorkspace, quiltModule').replace('quiltModule(', 'quiltWorkspace(), quiltModule(');
117
- if (!useReact) {
118
- quiltProject = quiltProject.replace('quiltPackage()', 'quiltPackage({react: false})');
119
- }
120
- await outputRoot.write('quilt.project.ts', await format(quiltProject, {
121
- as: 'typescript'
122
- }));
123
115
  await outputRoot.write('package.json', await format(JSON.stringify(combinedPackageJson), {
124
116
  as: 'json-stringify'
125
117
  }));
@@ -141,13 +133,23 @@ async function createModule() {
141
133
  }
142
134
 
143
135
  // We will adjust the entry file
144
- if (file === 'module.ts') {
145
- return false;
146
- }
136
+ if (file === 'module.ts') return false;
147
137
 
148
- // We need to make some adjustments the project’s package.json
149
- return file !== 'package.json';
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;
150
142
  });
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
+ }));
151
153
  await outputRoot.write(path.join(moduleDirectory, entry), await moduleTemplate.read('module.ts'));
152
154
  if (partOfMonorepo) {
153
155
  // Write the app’s package.json (the root one was already created)
@@ -97,10 +97,6 @@ async function createProject() {
97
97
  const outputRoot = createOutputTarget(rootDirectory);
98
98
  const packageTemplate = loadTemplate('package');
99
99
  const workspaceTemplate = loadTemplate('workspace');
100
- let quiltProject = await packageTemplate.read('quilt.project.ts');
101
- if (!useReact) {
102
- quiltProject = quiltProject.replace('quiltPackage()', 'quiltPackage({react: false})');
103
- }
104
100
 
105
101
  // If we aren’t already in a workspace, copy the workspace files over, which
106
102
  // are needed if we are making a monorepo or not.
@@ -144,10 +140,6 @@ async function createProject() {
144
140
  isPublic,
145
141
  registry: args['--registry']
146
142
  });
147
- quiltProject = quiltProject.replace('quiltPackage', 'quiltWorkspace, quiltPackage').replace('quiltPackage(', 'quiltWorkspace(), quiltPackage(');
148
- await outputRoot.write('quilt.project.ts', await format(quiltProject, {
149
- as: 'typescript'
150
- }));
151
143
  await outputRoot.write('package.json', await format(JSON.stringify(mergedPackageJson), {
152
144
  as: 'json-stringify'
153
145
  }));
@@ -171,6 +163,16 @@ async function createProject() {
171
163
  // We need to make some adjustments the project’s package.json, README, and Quilt config
172
164
  return file !== 'package.json' && file !== 'quilt.project.ts' && file !== 'README.md';
173
165
  });
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
+ }));
174
176
  await outputRoot.write(path.join(packageDirectory, 'README.md'), (await packageTemplate.read('README.md')).replaceAll('{{name}}', toValidPackageName(name)));
175
177
  if (partOfMonorepo) {
176
178
  // Write the package’s package.json (the root one was already created)
@@ -205,7 +207,6 @@ async function createProject() {
205
207
  await outputRoot.write(path.join(packageDirectory, 'package.json'), await format(JSON.stringify(projectPackageJson), {
206
208
  as: 'json-stringify'
207
209
  }));
208
- await outputRoot.write(path.join(packageDirectory, 'quilt.project.ts'), quiltProject);
209
210
  await Promise.all([addToTsConfig(packageDirectory, outputRoot), addToPackageManagerWorkspaces(packageDirectory, outputRoot, packageManager.type)]);
210
211
  }
211
212
  if (shouldInstall) {