@quilted/create 0.2.1 → 0.2.3
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/esm/app.mjs +32 -61
- package/build/esm/module.mjs +5 -7
- package/build/esm/package.mjs +4 -6
- package/build/esm/server.mjs +38 -72
- package/build/esnext/app.esnext +54 -80
- package/build/esnext/module.esnext +8 -10
- package/build/esnext/package.esnext +8 -10
- package/build/esnext/server.esnext +55 -87
- package/build/tsconfig.tsbuildinfo +1 -1
- package/build/typescript/app.d.ts.map +1 -1
- package/build/typescript/module.d.ts.map +1 -1
- package/build/typescript/package.d.ts.map +1 -1
- package/build/typescript/server.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/app.ts +66 -109
- package/source/module.ts +9 -11
- package/source/package.ts +8 -10
- package/source/server.ts +66 -116
- package/source/shared.ts +0 -1
- package/templates/app-basic/tsconfig.json +2 -2
- package/templates/app-empty/tsconfig.json +2 -2
- package/templates/app-graphql/package.json +5 -5
- package/templates/app-graphql/tsconfig.json +2 -2
- package/templates/app-trpc/package.json +10 -10
- package/templates/app-trpc/tsconfig.json +2 -2
- package/templates/module/tsconfig.json +1 -1
- package/templates/package/tsconfig.json +1 -1
- package/templates/server-basic/rollup.config.js +3 -0
- package/templates/server-basic/tsconfig.json +1 -1
- package/templates/workspace/_gitignore +1 -2
- package/templates/workspace/_prettierignore +1 -2
- package/templates/workspace/package.json +22 -26
- package/templates/workspace/tsconfig.json +2 -7
- package/tsconfig.json +1 -1
- package/templates/workspace-simple/_gitignore +0 -12
- package/templates/workspace-simple/_nvmrc +0 -1
- package/templates/workspace-simple/_prettierignore +0 -8
- package/templates/workspace-simple/package.json +0 -32
- package/templates/workspace-simple/tsconfig.json +0 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @quilted/create
|
|
2
2
|
|
|
3
|
+
## 0.2.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`c64ec21f`](https://github.com/lemonmade/quilt/commit/c64ec21f890af28c573b4a98bc07f4a0623e969d) Thanks [@lemonmade](https://github.com/lemonmade)! - Update TanStack Query dependencies
|
|
8
|
+
|
|
9
|
+
## 0.2.2
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`60b67a9a`](https://github.com/lemonmade/quilt/commit/60b67a9a38580dac93ec8d7c68c0a76422eabe09) Thanks [@lemonmade](https://github.com/lemonmade)! - Update more project templates
|
|
14
|
+
|
|
3
15
|
## 0.2.1
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/build/esm/app.mjs
CHANGED
|
@@ -18,7 +18,7 @@ import './node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLi
|
|
|
18
18
|
import stripIndent from './node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/stripIndent/stripIndent.mjs';
|
|
19
19
|
import './node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/stripIndents/stripIndents.mjs';
|
|
20
20
|
import { printHelp } from './help.mjs';
|
|
21
|
-
import { emptyDirectory,
|
|
21
|
+
import { emptyDirectory, loadTemplate, toValidPackageName, relativeDirectoryForDisplay, format, mergeWorkspaceAndProjectPackageJsons, isEmpty, createOutputTarget } from './shared.mjs';
|
|
22
22
|
import { getInWorkspace, getCreateAsMonorepo, getExtrasToSetup, getShouldInstall, getPackageManager } from './shared/prompts.mjs';
|
|
23
23
|
import { addToTsConfig } from './shared/tsconfig.mjs';
|
|
24
24
|
import { addToPackageManagerWorkspaces } from './shared/package-manager.mjs';
|
|
@@ -81,50 +81,11 @@ async function createApp() {
|
|
|
81
81
|
const outputRoot = createOutputTarget(rootDirectory);
|
|
82
82
|
const appTemplate = loadTemplate(`app-${template}`);
|
|
83
83
|
const workspaceTemplate = loadTemplate('workspace');
|
|
84
|
-
|
|
85
|
-
// If we aren’t already in a workspace, copy the workspace files over, which
|
|
86
|
-
// are needed if we are making a monorepo or not.
|
|
87
84
|
if (!inWorkspace) {
|
|
88
85
|
await workspaceTemplate.copy(directory, file => {
|
|
89
|
-
//
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
// We need to make some adjustments to the root package.json
|
|
93
|
-
if (file === 'package.json') return false;
|
|
94
|
-
return true;
|
|
86
|
+
// We will adjust the package.json before writing it
|
|
87
|
+
return file !== 'package.json';
|
|
95
88
|
});
|
|
96
|
-
|
|
97
|
-
// If we are creating a monorepo, we need to add the root package.json and
|
|
98
|
-
// package manager workspace configuration.
|
|
99
|
-
if (createAsMonorepo) {
|
|
100
|
-
const appRelativeToRoot = relativeDirectoryForDisplay(path.relative(directory, appDirectory));
|
|
101
|
-
const workspacePackageJson = JSON.parse(await workspaceTemplate.read('package.json'));
|
|
102
|
-
workspacePackageJson.name = toValidPackageName(name);
|
|
103
|
-
workspacePackageJson.workspaces = [appRelativeToRoot, './packages/*'];
|
|
104
|
-
if (packageManager.type === 'pnpm') {
|
|
105
|
-
await outputRoot.write('pnpm-workspace.yaml', await format(`
|
|
106
|
-
packages:
|
|
107
|
-
- '${appRelativeToRoot}'
|
|
108
|
-
- './packages/*'
|
|
109
|
-
`, {
|
|
110
|
-
as: 'yaml'
|
|
111
|
-
}));
|
|
112
|
-
}
|
|
113
|
-
await outputRoot.write('package.json', await format(JSON.stringify(workspacePackageJson), {
|
|
114
|
-
as: 'json-stringify'
|
|
115
|
-
}));
|
|
116
|
-
} else {
|
|
117
|
-
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))]);
|
|
118
|
-
const combinedPackageJson = mergeWorkspaceAndProjectPackageJsons(projectPackageJson, workspacePackageJson);
|
|
119
|
-
combinedPackageJson.name = toValidPackageName(name);
|
|
120
|
-
delete combinedPackageJson.workspaces;
|
|
121
|
-
await outputRoot.write('package.json', await format(JSON.stringify(combinedPackageJson), {
|
|
122
|
-
as: 'json-stringify'
|
|
123
|
-
}));
|
|
124
|
-
await outputRoot.write('tsconfig.json', await format(JSON.stringify(projectTSConfig), {
|
|
125
|
-
as: 'json'
|
|
126
|
-
}));
|
|
127
|
-
}
|
|
128
89
|
if (setupExtras.has('github')) {
|
|
129
90
|
await loadTemplate('github').copy(directory);
|
|
130
91
|
}
|
|
@@ -132,30 +93,28 @@ async function createApp() {
|
|
|
132
93
|
await loadTemplate('vscode').copy(directory);
|
|
133
94
|
}
|
|
134
95
|
}
|
|
96
|
+
if (createAsMonorepo) {
|
|
97
|
+
const workspacePackageJson = JSON.parse(await workspaceTemplate.read('package.json'));
|
|
98
|
+
workspacePackageJson.name = toValidPackageName(name);
|
|
99
|
+
const moduleRelativeToRoot = relativeDirectoryForDisplay(path.relative(directory, appDirectory));
|
|
100
|
+
await outputRoot.write('pnpm-workspace.yaml', await format(`
|
|
101
|
+
packages:
|
|
102
|
+
- './packages/*'
|
|
103
|
+
- '${moduleRelativeToRoot}'
|
|
104
|
+
`, {
|
|
105
|
+
as: 'yaml'
|
|
106
|
+
}));
|
|
107
|
+
await outputRoot.write('package.json', await format(JSON.stringify(workspacePackageJson), {
|
|
108
|
+
as: 'json-stringify'
|
|
109
|
+
}));
|
|
110
|
+
}
|
|
135
111
|
await appTemplate.copy(appDirectory, file => {
|
|
136
|
-
// If we are in a monorepo, we already wrote a merged tsconfig.json
|
|
137
|
-
if (file === 'tsconfig.json') {
|
|
138
|
-
return partOfMonorepo;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
112
|
// We need to merge the project gitignore with the workspace one
|
|
142
113
|
if (file === '_gitignore') return partOfMonorepo;
|
|
143
114
|
|
|
144
|
-
// We
|
|
145
|
-
|
|
146
|
-
if (file === 'package.json' || file === 'quilt.project.ts') return false;
|
|
147
|
-
return true;
|
|
115
|
+
// We will adjust the package.json before writing it
|
|
116
|
+
return file !== 'package.json';
|
|
148
117
|
});
|
|
149
|
-
let quiltProject = await appTemplate.read('quilt.project.ts');
|
|
150
|
-
if (!partOfMonorepo) {
|
|
151
|
-
quiltProject = quiltProject.replace('quiltApp', 'quiltWorkspace, quiltApp').replace('quiltApp(', 'quiltWorkspace(), quiltApp(');
|
|
152
|
-
if (await appTemplate.has('_gitignore')) {
|
|
153
|
-
await outputRoot.write(path.join(appDirectory, '.gitignore'), `${await outputRoot.read('.gitignore')}\n${await appTemplate.read('_gitignore')}`);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
await outputRoot.write(path.join(appDirectory, 'quilt.project.ts'), await format(quiltProject, {
|
|
157
|
-
as: 'typescript'
|
|
158
|
-
}));
|
|
159
118
|
if (template === 'graphql' && !inWorkspace) {
|
|
160
119
|
const relativeFromRootToAppPath = filePath => path.relative(outputRoot.root, path.join(appDirectory, filePath));
|
|
161
120
|
await outputRoot.write('graphql.config.ts', stripIndent`
|
|
@@ -182,6 +141,18 @@ async function createApp() {
|
|
|
182
141
|
as: 'json-stringify'
|
|
183
142
|
}));
|
|
184
143
|
await Promise.all([addToTsConfig(appDirectory, outputRoot), addToPackageManagerWorkspaces(appDirectory, outputRoot, packageManager.type)]);
|
|
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([appTemplate.read('package.json').then(content => JSON.parse(content)), workspaceTemplate.read('package.json').then(content => JSON.parse(content))]);
|
|
148
|
+
const mergedPackageJson = mergeWorkspaceAndProjectPackageJsons(projectPackageJson, workspacePackageJson);
|
|
149
|
+
mergedPackageJson.name = path.basename(appDirectory);
|
|
150
|
+
await outputRoot.write('package.json', await format(JSON.stringify(mergedPackageJson), {
|
|
151
|
+
as: 'json-stringify'
|
|
152
|
+
}));
|
|
153
|
+
if (await appTemplate.has('_gitignore')) {
|
|
154
|
+
await outputRoot.write(path.join(appDirectory, '.gitignore'), `${await outputRoot.read('.gitignore')}\n${await appTemplate.read('_gitignore')}`);
|
|
155
|
+
}
|
|
185
156
|
}
|
|
186
157
|
if (shouldInstall) {
|
|
187
158
|
console.log();
|
package/build/esm/module.mjs
CHANGED
|
@@ -79,7 +79,7 @@ async function createModule() {
|
|
|
79
79
|
const rootDirectory = inWorkspace ? process.cwd() : directory;
|
|
80
80
|
const outputRoot = createOutputTarget(rootDirectory);
|
|
81
81
|
const moduleTemplate = loadTemplate('module');
|
|
82
|
-
const workspaceTemplate = loadTemplate('workspace
|
|
82
|
+
const workspaceTemplate = loadTemplate('workspace');
|
|
83
83
|
if (!inWorkspace) {
|
|
84
84
|
await workspaceTemplate.copy(directory, file => {
|
|
85
85
|
// We will adjust the package.json before writing it
|
|
@@ -96,21 +96,19 @@ async function createModule() {
|
|
|
96
96
|
const workspacePackageJson = JSON.parse(await workspaceTemplate.read('package.json'));
|
|
97
97
|
workspacePackageJson.name = toValidPackageName(name);
|
|
98
98
|
const moduleRelativeToRoot = relativeDirectoryForDisplay(path.relative(directory, moduleDirectory));
|
|
99
|
-
|
|
100
|
-
await outputRoot.write('pnpm-workspace.yaml', await format(`
|
|
99
|
+
await outputRoot.write('pnpm-workspace.yaml', await format(`
|
|
101
100
|
packages:
|
|
102
101
|
- './packages/*'
|
|
103
102
|
- '${moduleRelativeToRoot}'
|
|
104
103
|
`, {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
104
|
+
as: 'yaml'
|
|
105
|
+
}));
|
|
108
106
|
await outputRoot.write('package.json', await format(JSON.stringify(workspacePackageJson), {
|
|
109
107
|
as: 'json-stringify'
|
|
110
108
|
}));
|
|
111
109
|
}
|
|
112
110
|
await moduleTemplate.copy(moduleDirectory, file => {
|
|
113
|
-
// We will adjust the package.json before writing
|
|
111
|
+
// We will adjust the package.json before writing it
|
|
114
112
|
return file !== 'package.json';
|
|
115
113
|
});
|
|
116
114
|
if (partOfMonorepo) {
|
package/build/esm/package.mjs
CHANGED
|
@@ -95,7 +95,7 @@ async function createProject() {
|
|
|
95
95
|
const rootDirectory = inWorkspace ? process.cwd() : directory;
|
|
96
96
|
const outputRoot = createOutputTarget(rootDirectory);
|
|
97
97
|
const packageTemplate = loadTemplate('package');
|
|
98
|
-
const workspaceTemplate = loadTemplate('workspace
|
|
98
|
+
const workspaceTemplate = loadTemplate('workspace');
|
|
99
99
|
if (!inWorkspace) {
|
|
100
100
|
await workspaceTemplate.copy(directory, file => {
|
|
101
101
|
// We will adjust the package.json before writing it
|
|
@@ -111,14 +111,12 @@ async function createProject() {
|
|
|
111
111
|
if (createAsMonorepo) {
|
|
112
112
|
const workspacePackageJson = JSON.parse(await workspaceTemplate.read('package.json'));
|
|
113
113
|
workspacePackageJson.name = toValidPackageName(name);
|
|
114
|
-
|
|
115
|
-
await outputRoot.write('pnpm-workspace.yaml', await format(`
|
|
114
|
+
await outputRoot.write('pnpm-workspace.yaml', await format(`
|
|
116
115
|
packages:
|
|
117
116
|
- './packages/*'
|
|
118
117
|
`, {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
118
|
+
as: 'yaml'
|
|
119
|
+
}));
|
|
122
120
|
await outputRoot.write('package.json', await format(JSON.stringify(workspacePackageJson), {
|
|
123
121
|
as: 'json-stringify'
|
|
124
122
|
}));
|
package/build/esm/server.mjs
CHANGED
|
@@ -18,7 +18,7 @@ import './node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLi
|
|
|
18
18
|
import stripIndent from './node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/stripIndent/stripIndent.mjs';
|
|
19
19
|
import './node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/stripIndents/stripIndents.mjs';
|
|
20
20
|
import { printHelp } from './help.mjs';
|
|
21
|
-
import { toValidPackageName, emptyDirectory, relativeDirectoryForDisplay, format, mergeWorkspaceAndProjectPackageJsons,
|
|
21
|
+
import { toValidPackageName, emptyDirectory, loadTemplate, relativeDirectoryForDisplay, format, mergeWorkspaceAndProjectPackageJsons, isEmpty, createOutputTarget } from './shared.mjs';
|
|
22
22
|
import { getInWorkspace, getCreateAsMonorepo, getExtrasToSetup, getShouldInstall, getPackageManager } from './shared/prompts.mjs';
|
|
23
23
|
import { addToTsConfig } from './shared/tsconfig.mjs';
|
|
24
24
|
import { addToPackageManagerWorkspaces } from './shared/package-manager.mjs';
|
|
@@ -53,16 +53,16 @@ async function createServer() {
|
|
|
53
53
|
root: directory
|
|
54
54
|
});
|
|
55
55
|
const partOfMonorepo = inWorkspace || createAsMonorepo;
|
|
56
|
-
const
|
|
56
|
+
const serverDirectory = createAsMonorepo ? path.join(directory, toValidPackageName(name)) : directory;
|
|
57
57
|
if (fs.existsSync(directory)) {
|
|
58
58
|
await emptyDirectory(directory);
|
|
59
|
-
if (
|
|
60
|
-
fs.mkdirSync(
|
|
59
|
+
if (serverDirectory !== directory) {
|
|
60
|
+
fs.mkdirSync(serverDirectory, {
|
|
61
61
|
recursive: true
|
|
62
62
|
});
|
|
63
63
|
}
|
|
64
64
|
} else {
|
|
65
|
-
fs.mkdirSync(
|
|
65
|
+
fs.mkdirSync(serverDirectory, {
|
|
66
66
|
recursive: true
|
|
67
67
|
});
|
|
68
68
|
}
|
|
@@ -70,53 +70,11 @@ async function createServer() {
|
|
|
70
70
|
const outputRoot = createOutputTarget(rootDirectory);
|
|
71
71
|
const serverTemplate = loadTemplate('server-basic');
|
|
72
72
|
const workspaceTemplate = loadTemplate('workspace');
|
|
73
|
-
|
|
74
|
-
// If we aren’t already in a workspace, copy the workspace files over, which
|
|
75
|
-
// are needed if we are making a monorepo or not.
|
|
76
73
|
if (!inWorkspace) {
|
|
77
74
|
await workspaceTemplate.copy(directory, file => {
|
|
78
|
-
//
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
// We need to make some adjustments to the root package.json
|
|
82
|
-
if (file === 'package.json') return false;
|
|
83
|
-
return true;
|
|
75
|
+
// We will adjust the package.json before writing it
|
|
76
|
+
return file !== 'package.json';
|
|
84
77
|
});
|
|
85
|
-
|
|
86
|
-
// If we are creating a monorepo, we need to add the root package.json and
|
|
87
|
-
// package manager workspace configuration.
|
|
88
|
-
if (createAsMonorepo) {
|
|
89
|
-
const serviceRelativeToRoot = relativeDirectoryForDisplay(path.relative(directory, serviceDirectory));
|
|
90
|
-
const workspacePackageJson = JSON.parse(await workspaceTemplate.read('package.json'));
|
|
91
|
-
workspacePackageJson.name = toValidPackageName(name);
|
|
92
|
-
workspacePackageJson.workspaces = [serviceRelativeToRoot, './packages/*'];
|
|
93
|
-
if (packageManager.type === 'pnpm') {
|
|
94
|
-
await outputRoot.write('pnpm-workspace.yaml', await format(`
|
|
95
|
-
packages:
|
|
96
|
-
- '${serviceRelativeToRoot}'
|
|
97
|
-
- './packages/*'
|
|
98
|
-
`, {
|
|
99
|
-
as: 'yaml'
|
|
100
|
-
}));
|
|
101
|
-
}
|
|
102
|
-
await outputRoot.write('package.json', await format(JSON.stringify(workspacePackageJson), {
|
|
103
|
-
as: 'json-stringify'
|
|
104
|
-
}));
|
|
105
|
-
} else {
|
|
106
|
-
const [projectPackageJson, projectTSConfig, workspacePackageJson] = await Promise.all([serverTemplate.read('package.json').then(content => JSON.parse(content)), serverTemplate.read('tsconfig.json').then(content => JSON.parse(content)), workspaceTemplate.read('package.json').then(content => JSON.parse(content))]);
|
|
107
|
-
const combinedPackageJson = mergeWorkspaceAndProjectPackageJsons(projectPackageJson, workspacePackageJson);
|
|
108
|
-
adjustPackageJson(combinedPackageJson, {
|
|
109
|
-
name,
|
|
110
|
-
entry
|
|
111
|
-
});
|
|
112
|
-
delete combinedPackageJson.workspaces;
|
|
113
|
-
await outputRoot.write('package.json', await format(JSON.stringify(combinedPackageJson), {
|
|
114
|
-
as: 'json-stringify'
|
|
115
|
-
}));
|
|
116
|
-
await outputRoot.write('tsconfig.json', await format(JSON.stringify(projectTSConfig), {
|
|
117
|
-
as: 'json'
|
|
118
|
-
}));
|
|
119
|
-
}
|
|
120
78
|
if (setupExtras.has('github')) {
|
|
121
79
|
await loadTemplate('github').copy(directory);
|
|
122
80
|
}
|
|
@@ -124,29 +82,25 @@ async function createServer() {
|
|
|
124
82
|
await loadTemplate('vscode').copy(directory);
|
|
125
83
|
}
|
|
126
84
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
85
|
+
if (createAsMonorepo) {
|
|
86
|
+
const workspacePackageJson = JSON.parse(await workspaceTemplate.read('package.json'));
|
|
87
|
+
workspacePackageJson.name = toValidPackageName(name);
|
|
88
|
+
const moduleRelativeToRoot = relativeDirectoryForDisplay(path.relative(directory, serverDirectory));
|
|
89
|
+
await outputRoot.write('pnpm-workspace.yaml', await format(`
|
|
90
|
+
packages:
|
|
91
|
+
- './packages/*'
|
|
92
|
+
- '${moduleRelativeToRoot}'
|
|
93
|
+
`, {
|
|
94
|
+
as: 'yaml'
|
|
95
|
+
}));
|
|
96
|
+
await outputRoot.write('package.json', await format(JSON.stringify(workspacePackageJson), {
|
|
97
|
+
as: 'json-stringify'
|
|
98
|
+
}));
|
|
99
|
+
}
|
|
100
|
+
await serverTemplate.copy(serverDirectory, file => {
|
|
101
|
+
// We will adjust the package.json before writing it
|
|
139
102
|
return file !== 'package.json';
|
|
140
103
|
});
|
|
141
|
-
let quiltProject = await serverTemplate.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
|
-
}));
|
|
149
|
-
await outputRoot.write(path.join(serviceDirectory, entry), await serverTemplate.read('service.ts'));
|
|
150
104
|
if (partOfMonorepo) {
|
|
151
105
|
// Write the app’s package.json (the root one was already created)
|
|
152
106
|
const projectPackageJson = JSON.parse(await serverTemplate.read('package.json'));
|
|
@@ -154,10 +108,22 @@ async function createServer() {
|
|
|
154
108
|
name,
|
|
155
109
|
entry
|
|
156
110
|
});
|
|
157
|
-
await outputRoot.write(path.join(
|
|
111
|
+
await outputRoot.write(path.join(serverDirectory, 'package.json'), await format(JSON.stringify(projectPackageJson), {
|
|
112
|
+
as: 'json-stringify'
|
|
113
|
+
}));
|
|
114
|
+
await Promise.all([addToTsConfig(serverDirectory, outputRoot), addToPackageManagerWorkspaces(serverDirectory, outputRoot, packageManager.type)]);
|
|
115
|
+
} else {
|
|
116
|
+
// Write the package’s package.json by combining elements of the root and
|
|
117
|
+
// package templates
|
|
118
|
+
const [projectPackageJson, workspacePackageJson] = await Promise.all([serverTemplate.read('package.json').then(content => JSON.parse(content)), workspaceTemplate.read('package.json').then(content => JSON.parse(content))]);
|
|
119
|
+
const mergedPackageJson = mergeWorkspaceAndProjectPackageJsons(projectPackageJson, workspacePackageJson);
|
|
120
|
+
adjustPackageJson(mergedPackageJson, {
|
|
121
|
+
name: toValidPackageName(name),
|
|
122
|
+
entry
|
|
123
|
+
});
|
|
124
|
+
await outputRoot.write('package.json', await format(JSON.stringify(mergedPackageJson), {
|
|
158
125
|
as: 'json-stringify'
|
|
159
126
|
}));
|
|
160
|
-
await Promise.all([addToTsConfig(serviceDirectory, outputRoot), addToPackageManagerWorkspaces(serviceDirectory, outputRoot, packageManager.type)]);
|
|
161
127
|
}
|
|
162
128
|
if (shouldInstall) {
|
|
163
129
|
console.log();
|
package/build/esnext/app.esnext
CHANGED
|
@@ -18,7 +18,7 @@ import './node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLi
|
|
|
18
18
|
import stripIndent from './node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/stripIndent/stripIndent.esnext';
|
|
19
19
|
import './node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/stripIndents/stripIndents.esnext';
|
|
20
20
|
import { printHelp } from './help.esnext';
|
|
21
|
-
import { emptyDirectory,
|
|
21
|
+
import { emptyDirectory, loadTemplate, toValidPackageName, relativeDirectoryForDisplay, format, mergeWorkspaceAndProjectPackageJsons, isEmpty, createOutputTarget } from './shared.esnext';
|
|
22
22
|
import { getInWorkspace, getCreateAsMonorepo, getExtrasToSetup, getShouldInstall, getPackageManager } from './shared/prompts.esnext';
|
|
23
23
|
import { addToTsConfig } from './shared/tsconfig.esnext';
|
|
24
24
|
import { addToPackageManagerWorkspaces } from './shared/package-manager.esnext';
|
|
@@ -77,63 +77,8 @@ async function createApp() {
|
|
|
77
77
|
const workspaceTemplate = loadTemplate("workspace");
|
|
78
78
|
if (!inWorkspace) {
|
|
79
79
|
await workspaceTemplate.copy(directory, (file) => {
|
|
80
|
-
|
|
81
|
-
return createAsMonorepo;
|
|
82
|
-
if (file === "package.json")
|
|
83
|
-
return false;
|
|
84
|
-
return true;
|
|
80
|
+
return file !== "package.json";
|
|
85
81
|
});
|
|
86
|
-
if (createAsMonorepo) {
|
|
87
|
-
const appRelativeToRoot = relativeDirectoryForDisplay(
|
|
88
|
-
path.relative(directory, appDirectory)
|
|
89
|
-
);
|
|
90
|
-
const workspacePackageJson = JSON.parse(
|
|
91
|
-
await workspaceTemplate.read("package.json")
|
|
92
|
-
);
|
|
93
|
-
workspacePackageJson.name = toValidPackageName(name);
|
|
94
|
-
workspacePackageJson.workspaces = [appRelativeToRoot, "./packages/*"];
|
|
95
|
-
if (packageManager.type === "pnpm") {
|
|
96
|
-
await outputRoot.write(
|
|
97
|
-
"pnpm-workspace.yaml",
|
|
98
|
-
await format(
|
|
99
|
-
`
|
|
100
|
-
packages:
|
|
101
|
-
- '${appRelativeToRoot}'
|
|
102
|
-
- './packages/*'
|
|
103
|
-
`,
|
|
104
|
-
{ as: "yaml" }
|
|
105
|
-
)
|
|
106
|
-
);
|
|
107
|
-
}
|
|
108
|
-
await outputRoot.write(
|
|
109
|
-
"package.json",
|
|
110
|
-
await format(JSON.stringify(workspacePackageJson), {
|
|
111
|
-
as: "json-stringify"
|
|
112
|
-
})
|
|
113
|
-
);
|
|
114
|
-
} else {
|
|
115
|
-
const [projectPackageJson, projectTSConfig, workspacePackageJson] = await Promise.all([
|
|
116
|
-
appTemplate.read("package.json").then((content) => JSON.parse(content)),
|
|
117
|
-
appTemplate.read("tsconfig.json").then((content) => JSON.parse(content)),
|
|
118
|
-
workspaceTemplate.read("package.json").then((content) => JSON.parse(content))
|
|
119
|
-
]);
|
|
120
|
-
const combinedPackageJson = mergeWorkspaceAndProjectPackageJsons(
|
|
121
|
-
projectPackageJson,
|
|
122
|
-
workspacePackageJson
|
|
123
|
-
);
|
|
124
|
-
combinedPackageJson.name = toValidPackageName(name);
|
|
125
|
-
delete combinedPackageJson.workspaces;
|
|
126
|
-
await outputRoot.write(
|
|
127
|
-
"package.json",
|
|
128
|
-
await format(JSON.stringify(combinedPackageJson), {
|
|
129
|
-
as: "json-stringify"
|
|
130
|
-
})
|
|
131
|
-
);
|
|
132
|
-
await outputRoot.write(
|
|
133
|
-
"tsconfig.json",
|
|
134
|
-
await format(JSON.stringify(projectTSConfig), { as: "json" })
|
|
135
|
-
);
|
|
136
|
-
}
|
|
137
82
|
if (setupExtras.has("github")) {
|
|
138
83
|
await loadTemplate("github").copy(directory);
|
|
139
84
|
}
|
|
@@ -141,33 +86,37 @@ async function createApp() {
|
|
|
141
86
|
await loadTemplate("vscode").copy(directory);
|
|
142
87
|
}
|
|
143
88
|
}
|
|
89
|
+
if (createAsMonorepo) {
|
|
90
|
+
const workspacePackageJson = JSON.parse(
|
|
91
|
+
await workspaceTemplate.read("package.json")
|
|
92
|
+
);
|
|
93
|
+
workspacePackageJson.name = toValidPackageName(name);
|
|
94
|
+
const moduleRelativeToRoot = relativeDirectoryForDisplay(
|
|
95
|
+
path.relative(directory, appDirectory)
|
|
96
|
+
);
|
|
97
|
+
await outputRoot.write(
|
|
98
|
+
"pnpm-workspace.yaml",
|
|
99
|
+
await format(
|
|
100
|
+
`
|
|
101
|
+
packages:
|
|
102
|
+
- './packages/*'
|
|
103
|
+
- '${moduleRelativeToRoot}'
|
|
104
|
+
`,
|
|
105
|
+
{ as: "yaml" }
|
|
106
|
+
)
|
|
107
|
+
);
|
|
108
|
+
await outputRoot.write(
|
|
109
|
+
"package.json",
|
|
110
|
+
await format(JSON.stringify(workspacePackageJson), {
|
|
111
|
+
as: "json-stringify"
|
|
112
|
+
})
|
|
113
|
+
);
|
|
114
|
+
}
|
|
144
115
|
await appTemplate.copy(appDirectory, (file) => {
|
|
145
|
-
if (file === "tsconfig.json") {
|
|
146
|
-
return partOfMonorepo;
|
|
147
|
-
}
|
|
148
116
|
if (file === "_gitignore")
|
|
149
117
|
return partOfMonorepo;
|
|
150
|
-
|
|
151
|
-
return false;
|
|
152
|
-
return true;
|
|
118
|
+
return file !== "package.json";
|
|
153
119
|
});
|
|
154
|
-
let quiltProject = await appTemplate.read("quilt.project.ts");
|
|
155
|
-
if (!partOfMonorepo) {
|
|
156
|
-
quiltProject = quiltProject.replace("quiltApp", "quiltWorkspace, quiltApp").replace("quiltApp(", "quiltWorkspace(), quiltApp(");
|
|
157
|
-
if (await appTemplate.has("_gitignore")) {
|
|
158
|
-
await outputRoot.write(
|
|
159
|
-
path.join(appDirectory, ".gitignore"),
|
|
160
|
-
`${await outputRoot.read(".gitignore")}
|
|
161
|
-
${await appTemplate.read(
|
|
162
|
-
"_gitignore"
|
|
163
|
-
)}`
|
|
164
|
-
);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
await outputRoot.write(
|
|
168
|
-
path.join(appDirectory, "quilt.project.ts"),
|
|
169
|
-
await format(quiltProject, { as: "typescript" })
|
|
170
|
-
);
|
|
171
120
|
if (template === "graphql" && !inWorkspace) {
|
|
172
121
|
const relativeFromRootToAppPath = (filePath) => path.relative(outputRoot.root, path.join(appDirectory, filePath));
|
|
173
122
|
await outputRoot.write(
|
|
@@ -210,6 +159,31 @@ ${await appTemplate.read(
|
|
|
210
159
|
packageManager.type
|
|
211
160
|
)
|
|
212
161
|
]);
|
|
162
|
+
} else {
|
|
163
|
+
const [projectPackageJson, workspacePackageJson] = await Promise.all([
|
|
164
|
+
appTemplate.read("package.json").then((content) => JSON.parse(content)),
|
|
165
|
+
workspaceTemplate.read("package.json").then((content) => JSON.parse(content))
|
|
166
|
+
]);
|
|
167
|
+
const mergedPackageJson = mergeWorkspaceAndProjectPackageJsons(
|
|
168
|
+
projectPackageJson,
|
|
169
|
+
workspacePackageJson
|
|
170
|
+
);
|
|
171
|
+
mergedPackageJson.name = path.basename(appDirectory);
|
|
172
|
+
await outputRoot.write(
|
|
173
|
+
"package.json",
|
|
174
|
+
await format(JSON.stringify(mergedPackageJson), {
|
|
175
|
+
as: "json-stringify"
|
|
176
|
+
})
|
|
177
|
+
);
|
|
178
|
+
if (await appTemplate.has("_gitignore")) {
|
|
179
|
+
await outputRoot.write(
|
|
180
|
+
path.join(appDirectory, ".gitignore"),
|
|
181
|
+
`${await outputRoot.read(".gitignore")}
|
|
182
|
+
${await appTemplate.read(
|
|
183
|
+
"_gitignore"
|
|
184
|
+
)}`
|
|
185
|
+
);
|
|
186
|
+
}
|
|
213
187
|
}
|
|
214
188
|
if (shouldInstall) {
|
|
215
189
|
console.log();
|
|
@@ -67,7 +67,7 @@ async function createModule() {
|
|
|
67
67
|
const rootDirectory = inWorkspace ? process.cwd() : directory;
|
|
68
68
|
const outputRoot = createOutputTarget(rootDirectory);
|
|
69
69
|
const moduleTemplate = loadTemplate("module");
|
|
70
|
-
const workspaceTemplate = loadTemplate("workspace
|
|
70
|
+
const workspaceTemplate = loadTemplate("workspace");
|
|
71
71
|
if (!inWorkspace) {
|
|
72
72
|
await workspaceTemplate.copy(directory, (file) => {
|
|
73
73
|
return file !== "package.json";
|
|
@@ -87,19 +87,17 @@ async function createModule() {
|
|
|
87
87
|
const moduleRelativeToRoot = relativeDirectoryForDisplay(
|
|
88
88
|
path.relative(directory, moduleDirectory)
|
|
89
89
|
);
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
`
|
|
90
|
+
await outputRoot.write(
|
|
91
|
+
"pnpm-workspace.yaml",
|
|
92
|
+
await format(
|
|
93
|
+
`
|
|
95
94
|
packages:
|
|
96
95
|
- './packages/*'
|
|
97
96
|
- '${moduleRelativeToRoot}'
|
|
98
97
|
`,
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
98
|
+
{ as: "yaml" }
|
|
99
|
+
)
|
|
100
|
+
);
|
|
103
101
|
await outputRoot.write(
|
|
104
102
|
"package.json",
|
|
105
103
|
await format(JSON.stringify(workspacePackageJson), {
|
|
@@ -89,7 +89,7 @@ async function createProject() {
|
|
|
89
89
|
const rootDirectory = inWorkspace ? process.cwd() : directory;
|
|
90
90
|
const outputRoot = createOutputTarget(rootDirectory);
|
|
91
91
|
const packageTemplate = loadTemplate("package");
|
|
92
|
-
const workspaceTemplate = loadTemplate("workspace
|
|
92
|
+
const workspaceTemplate = loadTemplate("workspace");
|
|
93
93
|
if (!inWorkspace) {
|
|
94
94
|
await workspaceTemplate.copy(directory, (file) => {
|
|
95
95
|
return file !== "package.json";
|
|
@@ -106,18 +106,16 @@ async function createProject() {
|
|
|
106
106
|
await workspaceTemplate.read("package.json")
|
|
107
107
|
);
|
|
108
108
|
workspacePackageJson.name = toValidPackageName(name);
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
`
|
|
109
|
+
await outputRoot.write(
|
|
110
|
+
"pnpm-workspace.yaml",
|
|
111
|
+
await format(
|
|
112
|
+
`
|
|
114
113
|
packages:
|
|
115
114
|
- './packages/*'
|
|
116
115
|
`,
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}
|
|
116
|
+
{ as: "yaml" }
|
|
117
|
+
)
|
|
118
|
+
);
|
|
121
119
|
await outputRoot.write(
|
|
122
120
|
"package.json",
|
|
123
121
|
await format(JSON.stringify(workspacePackageJson), {
|