@quilted/create 0.1.87 → 0.1.88
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/cjs/module.cjs +47 -79
- package/build/cjs/node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/prompts.cjs +1 -1
- package/build/cjs/node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/index.cjs +1 -1
- package/build/cjs/node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/prompts.cjs +1 -1
- package/build/cjs/package.cjs +1 -1
- package/build/cjs/shared.cjs +2 -1
- package/build/esm/module.mjs +47 -79
- package/build/esm/node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/prompts.mjs +1 -1
- package/build/esm/node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/index.mjs +1 -1
- package/build/esm/node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/prompts.mjs +1 -1
- package/build/esm/package.mjs +1 -1
- package/build/esnext/module.esnext +47 -79
- package/build/esnext/node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/prompts.esnext +1 -1
- package/build/esnext/node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/index.esnext +1 -1
- package/build/esnext/node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/lib/prompts.esnext +1 -1
- package/build/esnext/package.esnext +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/build/typescript/module.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/module.ts +83 -128
- package/source/package.ts +1 -1
- package/source/shared.ts +0 -2
- package/templates/module/module.ts +3 -1
- package/templates/module/package.json +6 -9
- package/templates/module/rollup.config.js +3 -0
- package/templates/module/tsconfig.json +1 -1
- package/templates/package/package.json +7 -11
- package/templates/package/tsconfig.json +1 -1
- package/templates/module/quilt.project.ts +0 -5
- package/templates/package/quilt.project.ts +0 -5
- package/templates/package/source/tests/index.test.ts +0 -8
- package/templates/package-simple/README.md +0 -1
- package/templates/package-simple/package.json +0 -49
- package/templates/package-simple/source/index.ts +0 -3
- package/templates/package-simple/tsconfig.json +0 -10
- /package/templates/{package-simple → package}/rollup.config.js +0 -0
- /package/templates/{package-simple → package}/source/index.test.ts +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @quilted/create
|
|
2
2
|
|
|
3
|
+
## 0.1.88
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`78f914d3`](https://github.com/lemonmade/quilt/commit/78f914d36e5a70b76ea9364529e9a00269065fb6) Thanks [@lemonmade](https://github.com/lemonmade)! - Add better module template
|
|
8
|
+
|
|
3
9
|
## 0.1.87
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/build/cjs/module.cjs
CHANGED
|
@@ -92,99 +92,67 @@ async function createModule() {
|
|
|
92
92
|
const rootDirectory = inWorkspace ? process.cwd() : directory;
|
|
93
93
|
const outputRoot = shared.createOutputTarget(rootDirectory);
|
|
94
94
|
const moduleTemplate = shared.loadTemplate('module');
|
|
95
|
-
const workspaceTemplate = shared.loadTemplate('workspace');
|
|
96
|
-
|
|
97
|
-
// If we aren’t already in a workspace, copy the workspace files over, which
|
|
98
|
-
// are needed if we are making a monorepo or not.
|
|
99
|
-
if (!inWorkspace) {
|
|
95
|
+
const workspaceTemplate = shared.loadTemplate('workspace-simple');
|
|
96
|
+
if (createAsMonorepo) {
|
|
100
97
|
await workspaceTemplate.copy(directory, file => {
|
|
101
|
-
//
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
// We need to make some adjustments to the root package.json
|
|
105
|
-
if (file === 'package.json') return false;
|
|
106
|
-
return true;
|
|
98
|
+
// We will adjust the package.json before writing it
|
|
99
|
+
return file !== 'package.json';
|
|
107
100
|
});
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
if (
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
packages:
|
|
119
|
-
- '${moduleRelativeToRoot}'
|
|
120
|
-
- './packages/*'
|
|
121
|
-
`, {
|
|
122
|
-
as: 'yaml'
|
|
123
|
-
}));
|
|
124
|
-
}
|
|
125
|
-
await outputRoot.write('package.json', await shared.format(JSON.stringify(workspacePackageJson), {
|
|
126
|
-
as: 'json-stringify'
|
|
127
|
-
}));
|
|
128
|
-
} else {
|
|
129
|
-
const [projectPackageJson, projectTSConfig, workspacePackageJson] = await Promise.all([moduleTemplate.read('package.json').then(content => JSON.parse(content)), moduleTemplate.read('tsconfig.json').then(content => JSON.parse(content)), workspaceTemplate.read('package.json').then(content => JSON.parse(content))]);
|
|
130
|
-
const combinedPackageJson = shared.mergeWorkspaceAndProjectPackageJsons(projectPackageJson, workspacePackageJson);
|
|
131
|
-
adjustPackageJson(combinedPackageJson, {
|
|
132
|
-
name,
|
|
133
|
-
entry,
|
|
134
|
-
react: useReact
|
|
135
|
-
});
|
|
136
|
-
delete combinedPackageJson.workspaces;
|
|
137
|
-
await outputRoot.write('package.json', await shared.format(JSON.stringify(combinedPackageJson), {
|
|
138
|
-
as: 'json-stringify'
|
|
139
|
-
}));
|
|
140
|
-
await outputRoot.write('tsconfig.json', await shared.format(JSON.stringify(projectTSConfig), {
|
|
141
|
-
as: 'json'
|
|
101
|
+
const workspacePackageJson = JSON.parse(await workspaceTemplate.read('package.json'));
|
|
102
|
+
workspacePackageJson.name = shared.toValidPackageName(name);
|
|
103
|
+
const moduleRelativeToRoot = shared.relativeDirectoryForDisplay(path__namespace.relative(directory, moduleDirectory));
|
|
104
|
+
if (packageManager$1.type === 'pnpm') {
|
|
105
|
+
await outputRoot.write('pnpm-workspace.yaml', await shared.format(`
|
|
106
|
+
packages:
|
|
107
|
+
- './packages/*'
|
|
108
|
+
- '${moduleRelativeToRoot}'
|
|
109
|
+
`, {
|
|
110
|
+
as: 'yaml'
|
|
142
111
|
}));
|
|
143
112
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
}
|
|
147
|
-
if (setupExtras.has('vscode')) {
|
|
148
|
-
await shared.loadTemplate('vscode').copy(directory);
|
|
149
|
-
}
|
|
113
|
+
await outputRoot.write('package.json', await shared.format(JSON.stringify(workspacePackageJson), {
|
|
114
|
+
as: 'json-stringify'
|
|
115
|
+
}));
|
|
150
116
|
}
|
|
151
117
|
await moduleTemplate.copy(moduleDirectory, file => {
|
|
152
|
-
//
|
|
153
|
-
|
|
154
|
-
return partOfMonorepo;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
// We will adjust the entry file
|
|
158
|
-
if (file === 'module.ts') return false;
|
|
159
|
-
|
|
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;
|
|
118
|
+
// We will adjust the package.json before writing them
|
|
119
|
+
return file !== 'package.json';
|
|
164
120
|
});
|
|
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
|
-
}));
|
|
175
|
-
await outputRoot.write(path__namespace.join(moduleDirectory, entry), await moduleTemplate.read('module.ts'));
|
|
176
121
|
if (partOfMonorepo) {
|
|
177
|
-
//
|
|
122
|
+
// Add the package to the workspace configuration files
|
|
123
|
+
await Promise.all([tsconfig.addToTsConfig(moduleDirectory, outputRoot), packageManager.addToPackageManagerWorkspaces(moduleDirectory, outputRoot, packageManager$1.type)]);
|
|
124
|
+
|
|
125
|
+
// Write the package’s package.json (the root one was already created)
|
|
178
126
|
const projectPackageJson = JSON.parse(await moduleTemplate.read('package.json'));
|
|
179
127
|
adjustPackageJson(projectPackageJson, {
|
|
180
|
-
name,
|
|
181
|
-
|
|
182
|
-
|
|
128
|
+
name: shared.toValidPackageName(name),
|
|
129
|
+
react: useReact,
|
|
130
|
+
entry
|
|
183
131
|
});
|
|
184
132
|
await outputRoot.write(path__namespace.join(moduleDirectory, 'package.json'), await shared.format(JSON.stringify(projectPackageJson), {
|
|
185
133
|
as: 'json-stringify'
|
|
186
134
|
}));
|
|
187
|
-
|
|
135
|
+
} else {
|
|
136
|
+
// Write the package’s package.json by combining elements of the root and
|
|
137
|
+
// package templates
|
|
138
|
+
const [projectPackageJson, workspacePackageJson] = await Promise.all([moduleTemplate.read('package.json').then(content => JSON.parse(content)), workspaceTemplate.read('package.json').then(content => JSON.parse(content))]);
|
|
139
|
+
const mergedPackageJson = shared.mergeWorkspaceAndProjectPackageJsons(projectPackageJson, workspacePackageJson);
|
|
140
|
+
adjustPackageJson(mergedPackageJson, {
|
|
141
|
+
name: shared.toValidPackageName(name),
|
|
142
|
+
react: useReact,
|
|
143
|
+
entry
|
|
144
|
+
});
|
|
145
|
+
await outputRoot.write('package.json', await shared.format(JSON.stringify(mergedPackageJson), {
|
|
146
|
+
as: 'json-stringify'
|
|
147
|
+
}));
|
|
148
|
+
}
|
|
149
|
+
if (!inWorkspace) {
|
|
150
|
+
if (setupExtras.has('github')) {
|
|
151
|
+
await shared.loadTemplate('github').copy(directory);
|
|
152
|
+
}
|
|
153
|
+
if (setupExtras.has('vscode')) {
|
|
154
|
+
await shared.loadTemplate('vscode').copy(directory);
|
|
155
|
+
}
|
|
188
156
|
}
|
|
189
157
|
if (shouldInstall) {
|
|
190
158
|
console.log();
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var _commonjsHelpers = require('../../../../../_virtual/_commonjsHelpers.cjs');
|
|
6
|
-
var index = require('./dist/index.cjs');
|
|
7
6
|
var index$1 = require('./lib/index.cjs');
|
|
7
|
+
var index = require('./dist/index.cjs');
|
|
8
8
|
|
|
9
9
|
function isNodeLT(tar) {
|
|
10
10
|
tar = (Array.isArray(tar) ? tar : tar.split('.')).map(Number);
|
package/build/cjs/package.cjs
CHANGED
|
@@ -116,7 +116,7 @@ async function createProject() {
|
|
|
116
116
|
}
|
|
117
117
|
const rootDirectory = inWorkspace ? process.cwd() : directory;
|
|
118
118
|
const outputRoot = shared.createOutputTarget(rootDirectory);
|
|
119
|
-
const packageTemplate = shared.loadTemplate('package
|
|
119
|
+
const packageTemplate = shared.loadTemplate('package');
|
|
120
120
|
const workspaceTemplate = shared.loadTemplate('workspace-simple');
|
|
121
121
|
if (createAsMonorepo) {
|
|
122
122
|
await workspaceTemplate.copy(directory, file => {
|
package/build/cjs/shared.cjs
CHANGED
|
@@ -4,6 +4,7 @@ var fs = require('node:fs');
|
|
|
4
4
|
var path = require('node:path');
|
|
5
5
|
var node_url = require('node:url');
|
|
6
6
|
|
|
7
|
+
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
7
8
|
function _interopNamespaceDefault(e) {
|
|
8
9
|
var n = Object.create(null);
|
|
9
10
|
if (e) {
|
|
@@ -80,7 +81,7 @@ async function getPackageRoot() {
|
|
|
80
81
|
packageDirectory
|
|
81
82
|
} = await Promise.resolve().then(function () { return require('./node_modules/.pnpm/pkg-dir@6.0.1/node_modules/pkg-dir/index.cjs'); });
|
|
82
83
|
return packageDirectory({
|
|
83
|
-
cwd: path__namespace.dirname(node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (
|
|
84
|
+
cwd: path__namespace.dirname(node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('shared.cjs', document.baseURI).href))))
|
|
84
85
|
});
|
|
85
86
|
})();
|
|
86
87
|
}
|
package/build/esm/module.mjs
CHANGED
|
@@ -70,99 +70,67 @@ async function createModule() {
|
|
|
70
70
|
const rootDirectory = inWorkspace ? process.cwd() : directory;
|
|
71
71
|
const outputRoot = createOutputTarget(rootDirectory);
|
|
72
72
|
const moduleTemplate = loadTemplate('module');
|
|
73
|
-
const workspaceTemplate = loadTemplate('workspace');
|
|
74
|
-
|
|
75
|
-
// If we aren’t already in a workspace, copy the workspace files over, which
|
|
76
|
-
// are needed if we are making a monorepo or not.
|
|
77
|
-
if (!inWorkspace) {
|
|
73
|
+
const workspaceTemplate = loadTemplate('workspace-simple');
|
|
74
|
+
if (createAsMonorepo) {
|
|
78
75
|
await workspaceTemplate.copy(directory, file => {
|
|
79
|
-
//
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
// We need to make some adjustments to the root package.json
|
|
83
|
-
if (file === 'package.json') return false;
|
|
84
|
-
return true;
|
|
76
|
+
// We will adjust the package.json before writing it
|
|
77
|
+
return file !== 'package.json';
|
|
85
78
|
});
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
if (
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
packages:
|
|
97
|
-
- '${moduleRelativeToRoot}'
|
|
98
|
-
- './packages/*'
|
|
99
|
-
`, {
|
|
100
|
-
as: 'yaml'
|
|
101
|
-
}));
|
|
102
|
-
}
|
|
103
|
-
await outputRoot.write('package.json', await format(JSON.stringify(workspacePackageJson), {
|
|
104
|
-
as: 'json-stringify'
|
|
105
|
-
}));
|
|
106
|
-
} else {
|
|
107
|
-
const [projectPackageJson, projectTSConfig, workspacePackageJson] = await Promise.all([moduleTemplate.read('package.json').then(content => JSON.parse(content)), moduleTemplate.read('tsconfig.json').then(content => JSON.parse(content)), workspaceTemplate.read('package.json').then(content => JSON.parse(content))]);
|
|
108
|
-
const combinedPackageJson = mergeWorkspaceAndProjectPackageJsons(projectPackageJson, workspacePackageJson);
|
|
109
|
-
adjustPackageJson(combinedPackageJson, {
|
|
110
|
-
name,
|
|
111
|
-
entry,
|
|
112
|
-
react: useReact
|
|
113
|
-
});
|
|
114
|
-
delete combinedPackageJson.workspaces;
|
|
115
|
-
await outputRoot.write('package.json', await format(JSON.stringify(combinedPackageJson), {
|
|
116
|
-
as: 'json-stringify'
|
|
117
|
-
}));
|
|
118
|
-
await outputRoot.write('tsconfig.json', await format(JSON.stringify(projectTSConfig), {
|
|
119
|
-
as: 'json'
|
|
79
|
+
const workspacePackageJson = JSON.parse(await workspaceTemplate.read('package.json'));
|
|
80
|
+
workspacePackageJson.name = toValidPackageName(name);
|
|
81
|
+
const moduleRelativeToRoot = relativeDirectoryForDisplay(path.relative(directory, moduleDirectory));
|
|
82
|
+
if (packageManager.type === 'pnpm') {
|
|
83
|
+
await outputRoot.write('pnpm-workspace.yaml', await format(`
|
|
84
|
+
packages:
|
|
85
|
+
- './packages/*'
|
|
86
|
+
- '${moduleRelativeToRoot}'
|
|
87
|
+
`, {
|
|
88
|
+
as: 'yaml'
|
|
120
89
|
}));
|
|
121
90
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}
|
|
125
|
-
if (setupExtras.has('vscode')) {
|
|
126
|
-
await loadTemplate('vscode').copy(directory);
|
|
127
|
-
}
|
|
91
|
+
await outputRoot.write('package.json', await format(JSON.stringify(workspacePackageJson), {
|
|
92
|
+
as: 'json-stringify'
|
|
93
|
+
}));
|
|
128
94
|
}
|
|
129
95
|
await moduleTemplate.copy(moduleDirectory, file => {
|
|
130
|
-
//
|
|
131
|
-
|
|
132
|
-
return partOfMonorepo;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
// We will adjust the entry file
|
|
136
|
-
if (file === 'module.ts') return false;
|
|
137
|
-
|
|
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;
|
|
96
|
+
// We will adjust the package.json before writing them
|
|
97
|
+
return file !== 'package.json';
|
|
142
98
|
});
|
|
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
|
-
}));
|
|
153
|
-
await outputRoot.write(path.join(moduleDirectory, entry), await moduleTemplate.read('module.ts'));
|
|
154
99
|
if (partOfMonorepo) {
|
|
155
|
-
//
|
|
100
|
+
// Add the package to the workspace configuration files
|
|
101
|
+
await Promise.all([addToTsConfig(moduleDirectory, outputRoot), addToPackageManagerWorkspaces(moduleDirectory, outputRoot, packageManager.type)]);
|
|
102
|
+
|
|
103
|
+
// Write the package’s package.json (the root one was already created)
|
|
156
104
|
const projectPackageJson = JSON.parse(await moduleTemplate.read('package.json'));
|
|
157
105
|
adjustPackageJson(projectPackageJson, {
|
|
158
|
-
name,
|
|
159
|
-
|
|
160
|
-
|
|
106
|
+
name: toValidPackageName(name),
|
|
107
|
+
react: useReact,
|
|
108
|
+
entry
|
|
161
109
|
});
|
|
162
110
|
await outputRoot.write(path.join(moduleDirectory, 'package.json'), await format(JSON.stringify(projectPackageJson), {
|
|
163
111
|
as: 'json-stringify'
|
|
164
112
|
}));
|
|
165
|
-
|
|
113
|
+
} else {
|
|
114
|
+
// Write the package’s package.json by combining elements of the root and
|
|
115
|
+
// package templates
|
|
116
|
+
const [projectPackageJson, workspacePackageJson] = await Promise.all([moduleTemplate.read('package.json').then(content => JSON.parse(content)), workspaceTemplate.read('package.json').then(content => JSON.parse(content))]);
|
|
117
|
+
const mergedPackageJson = mergeWorkspaceAndProjectPackageJsons(projectPackageJson, workspacePackageJson);
|
|
118
|
+
adjustPackageJson(mergedPackageJson, {
|
|
119
|
+
name: toValidPackageName(name),
|
|
120
|
+
react: useReact,
|
|
121
|
+
entry
|
|
122
|
+
});
|
|
123
|
+
await outputRoot.write('package.json', await format(JSON.stringify(mergedPackageJson), {
|
|
124
|
+
as: 'json-stringify'
|
|
125
|
+
}));
|
|
126
|
+
}
|
|
127
|
+
if (!inWorkspace) {
|
|
128
|
+
if (setupExtras.has('github')) {
|
|
129
|
+
await loadTemplate('github').copy(directory);
|
|
130
|
+
}
|
|
131
|
+
if (setupExtras.has('vscode')) {
|
|
132
|
+
await loadTemplate('vscode').copy(directory);
|
|
133
|
+
}
|
|
166
134
|
}
|
|
167
135
|
if (shouldInstall) {
|
|
168
136
|
console.log();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getDefaultExportFromCjs } from '../../../../../_virtual/_commonjsHelpers.mjs';
|
|
2
|
-
import { __require as requireDist } from './dist/index.mjs';
|
|
3
2
|
import { __require as requireLib } from './lib/index.mjs';
|
|
3
|
+
import { __require as requireDist } from './dist/index.mjs';
|
|
4
4
|
|
|
5
5
|
function isNodeLT(tar) {
|
|
6
6
|
tar = (Array.isArray(tar) ? tar : tar.split('.')).map(Number);
|
package/build/esm/package.mjs
CHANGED
|
@@ -94,7 +94,7 @@ async function createProject() {
|
|
|
94
94
|
}
|
|
95
95
|
const rootDirectory = inWorkspace ? process.cwd() : directory;
|
|
96
96
|
const outputRoot = createOutputTarget(rootDirectory);
|
|
97
|
-
const packageTemplate = loadTemplate('package
|
|
97
|
+
const packageTemplate = loadTemplate('package');
|
|
98
98
|
const workspaceTemplate = loadTemplate('workspace-simple');
|
|
99
99
|
if (createAsMonorepo) {
|
|
100
100
|
await workspaceTemplate.copy(directory, file => {
|
|
@@ -70,99 +70,67 @@ async function createModule() {
|
|
|
70
70
|
const rootDirectory = inWorkspace ? process.cwd() : directory;
|
|
71
71
|
const outputRoot = createOutputTarget(rootDirectory);
|
|
72
72
|
const moduleTemplate = loadTemplate('module');
|
|
73
|
-
const workspaceTemplate = loadTemplate('workspace');
|
|
74
|
-
|
|
75
|
-
// If we aren’t already in a workspace, copy the workspace files over, which
|
|
76
|
-
// are needed if we are making a monorepo or not.
|
|
77
|
-
if (!inWorkspace) {
|
|
73
|
+
const workspaceTemplate = loadTemplate('workspace-simple');
|
|
74
|
+
if (createAsMonorepo) {
|
|
78
75
|
await workspaceTemplate.copy(directory, file => {
|
|
79
|
-
//
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
// We need to make some adjustments to the root package.json
|
|
83
|
-
if (file === 'package.json') return false;
|
|
84
|
-
return true;
|
|
76
|
+
// We will adjust the package.json before writing it
|
|
77
|
+
return file !== 'package.json';
|
|
85
78
|
});
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
if (
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
packages:
|
|
97
|
-
- '${moduleRelativeToRoot}'
|
|
98
|
-
- './packages/*'
|
|
99
|
-
`, {
|
|
100
|
-
as: 'yaml'
|
|
101
|
-
}));
|
|
102
|
-
}
|
|
103
|
-
await outputRoot.write('package.json', await format(JSON.stringify(workspacePackageJson), {
|
|
104
|
-
as: 'json-stringify'
|
|
105
|
-
}));
|
|
106
|
-
} else {
|
|
107
|
-
const [projectPackageJson, projectTSConfig, workspacePackageJson] = await Promise.all([moduleTemplate.read('package.json').then(content => JSON.parse(content)), moduleTemplate.read('tsconfig.json').then(content => JSON.parse(content)), workspaceTemplate.read('package.json').then(content => JSON.parse(content))]);
|
|
108
|
-
const combinedPackageJson = mergeWorkspaceAndProjectPackageJsons(projectPackageJson, workspacePackageJson);
|
|
109
|
-
adjustPackageJson(combinedPackageJson, {
|
|
110
|
-
name,
|
|
111
|
-
entry,
|
|
112
|
-
react: useReact
|
|
113
|
-
});
|
|
114
|
-
delete combinedPackageJson.workspaces;
|
|
115
|
-
await outputRoot.write('package.json', await format(JSON.stringify(combinedPackageJson), {
|
|
116
|
-
as: 'json-stringify'
|
|
117
|
-
}));
|
|
118
|
-
await outputRoot.write('tsconfig.json', await format(JSON.stringify(projectTSConfig), {
|
|
119
|
-
as: 'json'
|
|
79
|
+
const workspacePackageJson = JSON.parse(await workspaceTemplate.read('package.json'));
|
|
80
|
+
workspacePackageJson.name = toValidPackageName(name);
|
|
81
|
+
const moduleRelativeToRoot = relativeDirectoryForDisplay(path.relative(directory, moduleDirectory));
|
|
82
|
+
if (packageManager.type === 'pnpm') {
|
|
83
|
+
await outputRoot.write('pnpm-workspace.yaml', await format(`
|
|
84
|
+
packages:
|
|
85
|
+
- './packages/*'
|
|
86
|
+
- '${moduleRelativeToRoot}'
|
|
87
|
+
`, {
|
|
88
|
+
as: 'yaml'
|
|
120
89
|
}));
|
|
121
90
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}
|
|
125
|
-
if (setupExtras.has('vscode')) {
|
|
126
|
-
await loadTemplate('vscode').copy(directory);
|
|
127
|
-
}
|
|
91
|
+
await outputRoot.write('package.json', await format(JSON.stringify(workspacePackageJson), {
|
|
92
|
+
as: 'json-stringify'
|
|
93
|
+
}));
|
|
128
94
|
}
|
|
129
95
|
await moduleTemplate.copy(moduleDirectory, file => {
|
|
130
|
-
//
|
|
131
|
-
|
|
132
|
-
return partOfMonorepo;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
// We will adjust the entry file
|
|
136
|
-
if (file === 'module.ts') return false;
|
|
137
|
-
|
|
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;
|
|
96
|
+
// We will adjust the package.json before writing them
|
|
97
|
+
return file !== 'package.json';
|
|
142
98
|
});
|
|
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
|
-
}));
|
|
153
|
-
await outputRoot.write(path.join(moduleDirectory, entry), await moduleTemplate.read('module.ts'));
|
|
154
99
|
if (partOfMonorepo) {
|
|
155
|
-
//
|
|
100
|
+
// Add the package to the workspace configuration files
|
|
101
|
+
await Promise.all([addToTsConfig(moduleDirectory, outputRoot), addToPackageManagerWorkspaces(moduleDirectory, outputRoot, packageManager.type)]);
|
|
102
|
+
|
|
103
|
+
// Write the package’s package.json (the root one was already created)
|
|
156
104
|
const projectPackageJson = JSON.parse(await moduleTemplate.read('package.json'));
|
|
157
105
|
adjustPackageJson(projectPackageJson, {
|
|
158
|
-
name,
|
|
159
|
-
|
|
160
|
-
|
|
106
|
+
name: toValidPackageName(name),
|
|
107
|
+
react: useReact,
|
|
108
|
+
entry
|
|
161
109
|
});
|
|
162
110
|
await outputRoot.write(path.join(moduleDirectory, 'package.json'), await format(JSON.stringify(projectPackageJson), {
|
|
163
111
|
as: 'json-stringify'
|
|
164
112
|
}));
|
|
165
|
-
|
|
113
|
+
} else {
|
|
114
|
+
// Write the package’s package.json by combining elements of the root and
|
|
115
|
+
// package templates
|
|
116
|
+
const [projectPackageJson, workspacePackageJson] = await Promise.all([moduleTemplate.read('package.json').then(content => JSON.parse(content)), workspaceTemplate.read('package.json').then(content => JSON.parse(content))]);
|
|
117
|
+
const mergedPackageJson = mergeWorkspaceAndProjectPackageJsons(projectPackageJson, workspacePackageJson);
|
|
118
|
+
adjustPackageJson(mergedPackageJson, {
|
|
119
|
+
name: toValidPackageName(name),
|
|
120
|
+
react: useReact,
|
|
121
|
+
entry
|
|
122
|
+
});
|
|
123
|
+
await outputRoot.write('package.json', await format(JSON.stringify(mergedPackageJson), {
|
|
124
|
+
as: 'json-stringify'
|
|
125
|
+
}));
|
|
126
|
+
}
|
|
127
|
+
if (!inWorkspace) {
|
|
128
|
+
if (setupExtras.has('github')) {
|
|
129
|
+
await loadTemplate('github').copy(directory);
|
|
130
|
+
}
|
|
131
|
+
if (setupExtras.has('vscode')) {
|
|
132
|
+
await loadTemplate('vscode').copy(directory);
|
|
133
|
+
}
|
|
166
134
|
}
|
|
167
135
|
if (shouldInstall) {
|
|
168
136
|
console.log();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getDefaultExportFromCjs } from '../../../../../_virtual/_commonjsHelpers.esnext';
|
|
2
|
-
import { __require as requireDist } from './dist/index.esnext';
|
|
3
2
|
import { __require as requireLib } from './lib/index.esnext';
|
|
3
|
+
import { __require as requireDist } from './dist/index.esnext';
|
|
4
4
|
|
|
5
5
|
function isNodeLT(tar) {
|
|
6
6
|
tar = (Array.isArray(tar) ? tar : tar.split('.')).map(Number);
|
|
@@ -94,7 +94,7 @@ async function createProject() {
|
|
|
94
94
|
}
|
|
95
95
|
const rootDirectory = inWorkspace ? process.cwd() : directory;
|
|
96
96
|
const outputRoot = createOutputTarget(rootDirectory);
|
|
97
|
-
const packageTemplate = loadTemplate('package
|
|
97
|
+
const packageTemplate = loadTemplate('package');
|
|
98
98
|
const workspaceTemplate = loadTemplate('workspace-simple');
|
|
99
99
|
if (createAsMonorepo) {
|
|
100
100
|
await workspaceTemplate.copy(directory, file => {
|