@quilted/create 0.1.18 → 0.1.21
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 +18 -0
- package/build/cjs/app.cjs +525 -236
- package/build/cjs/index.cjs +1020 -233
- package/build/cjs/index3.cjs +577 -1205
- package/build/cjs/package-manager.cjs +801 -199
- package/build/cjs/package.cjs +702 -320
- package/build/esm/app.mjs +530 -241
- package/build/esm/index.mjs +1002 -219
- package/build/esm/index3.mjs +548 -1205
- package/build/esm/package-manager.mjs +801 -200
- package/build/esm/package.mjs +702 -320
- package/build/tsconfig.tsbuildinfo +1 -1
- package/build/typescript/package.d.ts +1 -1
- package/package.json +5 -3
- package/quilt.project.ts +19 -5
- package/source/create.ts +2 -2
- package/source/package.ts +1 -1
- package/templates/app-basic/quilt.project.ts +5 -5
- package/templates/app-basic/tsconfig.json +1 -1
- package/templates/app-single-file/quilt.project.ts +3 -4
- package/templates/app-single-file/tsconfig.json +1 -1
- package/templates/package/package.json +3 -2
- package/templates/package/quilt.project.ts +3 -4
- package/templates/package/tsconfig.json +1 -1
- package/templates/workspace/package.json +1 -1
- package/tsconfig.json +1 -1
package/build/esm/app.mjs
CHANGED
|
@@ -1,192 +1,365 @@
|
|
|
1
|
+
import { r as relativeDirectoryForDisplay, a as addToTsConfig, b as addToPackageManagerWorkspaces, f as format, l as loadTemplate, _ as _slicedToArray, t as toValidPackageName, c as createOutputTarget, e as emptyDirectory, i as isEmpty } from './package-manager.mjs';
|
|
2
|
+
import { _ as _asyncToGenerator, r as regenerator, c as cyan_1, d as dim_1, s as stripIndent, a as _taggedTemplateLiteral, u as underline_1, m as magenta_1, g as getExtrasToSetup, b as getPackageManager, e as getShouldInstall, f as getCreateAsMonorepo, h as bold_1, p as printHelp, i as arg_1, j as prompt } from './index.mjs';
|
|
1
3
|
import * as fs from 'fs';
|
|
2
4
|
import * as path from 'path';
|
|
3
5
|
import { execSync } from 'child_process';
|
|
4
|
-
import { s as stripIndent, c as cyan_1, b as bold_1, p as printHelp, g as getCreateAsMonorepo, a as getShouldInstall, d as getPackageManager, e as getExtrasToSetup, f as dim_1, u as underline_1, m as magenta_1, h as arg_1, i as prompt } from './index.mjs';
|
|
5
|
-
import { e as emptyDirectory, t as toValidPackageName, f as format, l as loadTemplate, a as addToTsConfig, b as addToPackageManagerWorkspaces, r as relativeDirectoryForDisplay, i as isEmpty, c as createOutputTarget } from './package-manager.mjs';
|
|
6
|
-
import 'tty';
|
|
7
6
|
import 'url';
|
|
7
|
+
import 'tty';
|
|
8
8
|
import 'readline';
|
|
9
9
|
import 'events';
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
if (argv['--help']) {
|
|
15
|
-
const additionalOptions = stripIndent`
|
|
16
|
-
${cyan_1(`--template`)}
|
|
17
|
-
The template to use for your new application. If you don’t specify a template,
|
|
18
|
-
this command will ask you for one instead. Must be one of the following:
|
|
19
|
-
|
|
20
|
-
- ${bold_1('basic')}, a web app with a minimal file structure
|
|
21
|
-
- ${bold_1('single-file')}, an entire web app in a single file
|
|
22
|
-
`;
|
|
23
|
-
printHelp({
|
|
24
|
-
kind: 'app',
|
|
25
|
-
options: additionalOptions,
|
|
26
|
-
packageManager: argv['--package-manager']?.toLowerCase()
|
|
27
|
-
});
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const inWorkspace = fs.existsSync('quilt.workspace.ts');
|
|
32
|
-
const name = await getName(argv, {
|
|
33
|
-
inWorkspace
|
|
34
|
-
});
|
|
35
|
-
const directory = await getDirectory(argv, {
|
|
36
|
-
name
|
|
37
|
-
});
|
|
38
|
-
const template = await getTemplate(argv);
|
|
39
|
-
const createAsMonorepo = !inWorkspace && (await getCreateAsMonorepo(argv));
|
|
40
|
-
const shouldInstall = await getShouldInstall(argv);
|
|
41
|
-
const packageManager = await getPackageManager(argv);
|
|
42
|
-
const setupExtras = await getExtrasToSetup(argv, {
|
|
43
|
-
inWorkspace
|
|
44
|
-
});
|
|
45
|
-
const partOfMonorepo = inWorkspace || createAsMonorepo;
|
|
46
|
-
const appDirectory = createAsMonorepo ? path.join(directory, 'app') : directory;
|
|
47
|
-
|
|
48
|
-
if (fs.existsSync(directory)) {
|
|
49
|
-
await emptyDirectory(directory);
|
|
50
|
-
|
|
51
|
-
if (appDirectory !== directory) {
|
|
52
|
-
fs.mkdirSync(appDirectory, {
|
|
53
|
-
recursive: true
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
} else {
|
|
57
|
-
fs.mkdirSync(appDirectory, {
|
|
58
|
-
recursive: true
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const rootDirectory = inWorkspace ? process.cwd() : directory;
|
|
63
|
-
const outputRoot = createOutputTarget(rootDirectory);
|
|
64
|
-
const appTemplate = loadTemplate(template === 'basic' ? 'app-basic' : 'app-single-file');
|
|
65
|
-
const workspaceTemplate = loadTemplate('workspace'); // If we aren’t already in a workspace, copy the workspace files over, which
|
|
66
|
-
// are needed if we are making a monorepo or not.
|
|
67
|
-
|
|
68
|
-
if (!inWorkspace) {
|
|
69
|
-
await workspaceTemplate.copy(directory, file => {
|
|
70
|
-
// When this is a single project, we use the project’s Quilt configuration as the base.
|
|
71
|
-
if (file === 'quilt.workspace.ts') return createAsMonorepo; // We need to make some adjustments to the root package.json
|
|
72
|
-
|
|
73
|
-
return file !== 'package.json';
|
|
74
|
-
}); // If we are creating a monorepo, we need to add the root package.json and
|
|
75
|
-
// package manager workspace configuration.
|
|
76
|
-
|
|
77
|
-
if (createAsMonorepo) {
|
|
78
|
-
const workspacePackageJson = JSON.parse(await workspaceTemplate.read('package.json'));
|
|
79
|
-
workspacePackageJson.name = toValidPackageName(name);
|
|
80
|
-
|
|
81
|
-
if (packageManager === 'pnpm') {
|
|
82
|
-
await outputRoot.write('pnpm-workspace.yaml', await format(`
|
|
83
|
-
packages:
|
|
84
|
-
- './packages/*'
|
|
85
|
-
`, {
|
|
86
|
-
as: 'yaml'
|
|
87
|
-
}));
|
|
88
|
-
} else {
|
|
89
|
-
workspacePackageJson.workspaces = ['packages/*'];
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
await outputRoot.write('package.json', await format(JSON.stringify(workspacePackageJson), {
|
|
93
|
-
as: 'json-stringify'
|
|
94
|
-
}));
|
|
95
|
-
} else {
|
|
96
|
-
const [projectPackageJson, projectTSConfig, workspacePackageJson] = await Promise.all([appTemplate.read('package.json').then(content => JSON.parse(content)), appTemplate.read('tsconfig.json').then(content => JSON.parse(content)), workspaceTemplate.read('package.json').then(content => JSON.parse(content))]);
|
|
97
|
-
workspacePackageJson.name = toValidPackageName(name);
|
|
98
|
-
workspacePackageJson.eslintConfig = projectPackageJson.eslintConfig;
|
|
99
|
-
workspacePackageJson.browserslist = projectPackageJson.browserslist;
|
|
100
|
-
let quiltProject = await appTemplate.read('quilt.project.ts');
|
|
101
|
-
quiltProject = quiltProject.replace('quiltApp', 'quiltWorkspace, quiltApp').replace('quiltApp(', 'quiltWorkspace(), quiltApp(');
|
|
102
|
-
await outputRoot.write('quilt.project.ts', await format(quiltProject, {
|
|
103
|
-
as: 'typescript'
|
|
104
|
-
}));
|
|
105
|
-
await outputRoot.write('package.json', await format(JSON.stringify(workspacePackageJson), {
|
|
106
|
-
as: 'json-stringify'
|
|
107
|
-
}));
|
|
108
|
-
await outputRoot.write('tsconfig.json', await format(JSON.stringify(projectTSConfig), {
|
|
109
|
-
as: 'json'
|
|
110
|
-
}));
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
if (setupExtras.has('github')) {
|
|
114
|
-
await loadTemplate('github').copy(directory);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
if (setupExtras.has('vscode')) {
|
|
118
|
-
await loadTemplate('vscode').copy(directory);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
await appTemplate.copy(appDirectory, file => {
|
|
123
|
-
// If we are in a monorepo, we can use all the template files as they are
|
|
124
|
-
if (file === 'quilt.project.ts' || file === 'tsconfig.json') {
|
|
125
|
-
return partOfMonorepo;
|
|
126
|
-
} // We need to make some adjustments the project’s package.json
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
return file !== 'package.json';
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
if (partOfMonorepo) {
|
|
133
|
-
// Write the app’s package.json (the root one was already created)
|
|
134
|
-
const projectPackageJson = JSON.parse(await appTemplate.read('package.json'));
|
|
135
|
-
projectPackageJson.name = path.basename(appDirectory);
|
|
136
|
-
await outputRoot.write(path.join(appDirectory, 'package.json'), await format(JSON.stringify(projectPackageJson), {
|
|
137
|
-
as: 'json-stringify'
|
|
138
|
-
}));
|
|
139
|
-
await Promise.all([addToTsConfig(appDirectory, outputRoot), addToPackageManagerWorkspaces(appDirectory, outputRoot, packageManager)]);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
if (shouldInstall) {
|
|
143
|
-
process.stdout.write('\nInstalling dependencies...\n'); // TODO: better loading, handle errors
|
|
144
|
-
|
|
145
|
-
execSync(`${packageManager} install`, {
|
|
146
|
-
cwd: rootDirectory
|
|
147
|
-
});
|
|
148
|
-
process.stdout.moveCursor(0, -1);
|
|
149
|
-
process.stdout.clearLine(1);
|
|
150
|
-
console.log('Installed dependencies.');
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
const commands = [];
|
|
154
|
-
|
|
155
|
-
if (!inWorkspace && directory !== process.cwd()) {
|
|
156
|
-
commands.push(`cd ${cyan_1(relativeDirectoryForDisplay(path.relative(process.cwd(), directory)))} ${dim_1('# Move into your new app’s directory')}`);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
if (!shouldInstall) {
|
|
160
|
-
commands.push(`pnpm install ${dim_1('# Install all your dependencies')}`);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
if (!inWorkspace) {
|
|
164
|
-
// TODO: change this condition to check if git was initialized already
|
|
165
|
-
commands.push(`git init && git add -A && git commit -m "Initial commit" ${dim_1('# Start your git history (optional)')}`);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
commands.push(`pnpm develop ${dim_1('# Start the development server')}`);
|
|
169
|
-
const whatsNext = stripIndent`
|
|
170
|
-
Your new app is ready to go! There’s just ${commands.length > 1 ? 'a few more steps' : 'one more step'} you’ll need to take
|
|
171
|
-
in order to start developing:
|
|
172
|
-
`;
|
|
173
|
-
console.log();
|
|
174
|
-
console.log(whatsNext);
|
|
175
|
-
console.log();
|
|
176
|
-
console.log(commands.map(command => ` ${command}`).join('\n'));
|
|
177
|
-
const followUp = stripIndent`
|
|
178
|
-
Quilt can also help you build, test, lint, and type-check your new application.
|
|
179
|
-
You can learn more about building apps with Quilt by reading the documentation:
|
|
180
|
-
${underline_1(magenta_1('https://github.com/lemonmade/quilt/tree/main/documentation'))}
|
|
181
|
-
|
|
182
|
-
Have fun! 🎉
|
|
183
|
-
`;
|
|
184
|
-
console.log();
|
|
185
|
-
console.log(followUp);
|
|
11
|
+
var _templateObject, _templateObject2, _templateObject3;
|
|
12
|
+
function createApp() {
|
|
13
|
+
return _createApp.apply(this, arguments);
|
|
186
14
|
} // Argument handling
|
|
187
15
|
|
|
16
|
+
function _createApp() {
|
|
17
|
+
_createApp = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
|
|
18
|
+
var argv, _argv$PackageManag, additionalOptions, inWorkspace, name, directory, template, createAsMonorepo, shouldInstall, packageManager, setupExtras, partOfMonorepo, appDirectory, rootDirectory, outputRoot, appTemplate, workspaceTemplate, workspacePackageJson, _yield$Promise$all, _yield$Promise$all2, projectPackageJson, projectTSConfig, _workspacePackageJson, quiltProject, _projectPackageJson, commands, whatsNext, followUp;
|
|
19
|
+
|
|
20
|
+
return regenerator.wrap(function _callee$(_context) {
|
|
21
|
+
while (1) {
|
|
22
|
+
switch (_context.prev = _context.next) {
|
|
23
|
+
case 0:
|
|
24
|
+
argv = getArgv();
|
|
25
|
+
|
|
26
|
+
if (!argv['--help']) {
|
|
27
|
+
_context.next = 5;
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
additionalOptions = stripIndent(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n ", "\n The template to use for your new application. If you don\u2019t specify a template,\n this command will ask you for one instead. Must be one of the following:\n\n - ", ", a web app with a minimal file structure\n - ", ", an entire web app in a single file\n "])), cyan_1("--template"), bold_1('basic'), bold_1('single-file'));
|
|
32
|
+
printHelp({
|
|
33
|
+
kind: 'app',
|
|
34
|
+
options: additionalOptions,
|
|
35
|
+
packageManager: (_argv$PackageManag = argv['--package-manager']) === null || _argv$PackageManag === void 0 ? void 0 : _argv$PackageManag.toLowerCase()
|
|
36
|
+
});
|
|
37
|
+
return _context.abrupt("return");
|
|
38
|
+
|
|
39
|
+
case 5:
|
|
40
|
+
inWorkspace = fs.existsSync('quilt.workspace.ts');
|
|
41
|
+
_context.next = 8;
|
|
42
|
+
return getName(argv, {
|
|
43
|
+
inWorkspace: inWorkspace
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
case 8:
|
|
47
|
+
name = _context.sent;
|
|
48
|
+
_context.next = 11;
|
|
49
|
+
return getDirectory(argv, {
|
|
50
|
+
name: name
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
case 11:
|
|
54
|
+
directory = _context.sent;
|
|
55
|
+
_context.next = 14;
|
|
56
|
+
return getTemplate(argv);
|
|
57
|
+
|
|
58
|
+
case 14:
|
|
59
|
+
template = _context.sent;
|
|
60
|
+
_context.t0 = !inWorkspace;
|
|
61
|
+
|
|
62
|
+
if (!_context.t0) {
|
|
63
|
+
_context.next = 20;
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
_context.next = 19;
|
|
68
|
+
return getCreateAsMonorepo(argv);
|
|
69
|
+
|
|
70
|
+
case 19:
|
|
71
|
+
_context.t0 = _context.sent;
|
|
72
|
+
|
|
73
|
+
case 20:
|
|
74
|
+
createAsMonorepo = _context.t0;
|
|
75
|
+
_context.next = 23;
|
|
76
|
+
return getShouldInstall(argv);
|
|
77
|
+
|
|
78
|
+
case 23:
|
|
79
|
+
shouldInstall = _context.sent;
|
|
80
|
+
_context.next = 26;
|
|
81
|
+
return getPackageManager(argv);
|
|
82
|
+
|
|
83
|
+
case 26:
|
|
84
|
+
packageManager = _context.sent;
|
|
85
|
+
_context.next = 29;
|
|
86
|
+
return getExtrasToSetup(argv, {
|
|
87
|
+
inWorkspace: inWorkspace
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
case 29:
|
|
91
|
+
setupExtras = _context.sent;
|
|
92
|
+
partOfMonorepo = inWorkspace || createAsMonorepo;
|
|
93
|
+
appDirectory = createAsMonorepo ? path.join(directory, 'app') : directory;
|
|
94
|
+
|
|
95
|
+
if (!fs.existsSync(directory)) {
|
|
96
|
+
_context.next = 38;
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
_context.next = 35;
|
|
101
|
+
return emptyDirectory(directory);
|
|
102
|
+
|
|
103
|
+
case 35:
|
|
104
|
+
if (appDirectory !== directory) {
|
|
105
|
+
fs.mkdirSync(appDirectory, {
|
|
106
|
+
recursive: true
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
_context.next = 39;
|
|
111
|
+
break;
|
|
112
|
+
|
|
113
|
+
case 38:
|
|
114
|
+
fs.mkdirSync(appDirectory, {
|
|
115
|
+
recursive: true
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
case 39:
|
|
119
|
+
rootDirectory = inWorkspace ? process.cwd() : directory;
|
|
120
|
+
outputRoot = createOutputTarget(rootDirectory);
|
|
121
|
+
appTemplate = loadTemplate(template === 'basic' ? 'app-basic' : 'app-single-file');
|
|
122
|
+
workspaceTemplate = loadTemplate('workspace'); // If we aren’t already in a workspace, copy the workspace files over, which
|
|
123
|
+
// are needed if we are making a monorepo or not.
|
|
124
|
+
|
|
125
|
+
if (inWorkspace) {
|
|
126
|
+
_context.next = 109;
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
_context.next = 46;
|
|
131
|
+
return workspaceTemplate.copy(directory, function (file) {
|
|
132
|
+
// When this is a single project, we use the project’s Quilt configuration as the base.
|
|
133
|
+
if (file === 'quilt.workspace.ts') return createAsMonorepo; // We need to make some adjustments to the root package.json
|
|
134
|
+
|
|
135
|
+
return file !== 'package.json';
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
case 46:
|
|
139
|
+
if (!createAsMonorepo) {
|
|
140
|
+
_context.next = 71;
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
_context.t1 = JSON;
|
|
145
|
+
_context.next = 50;
|
|
146
|
+
return workspaceTemplate.read('package.json');
|
|
147
|
+
|
|
148
|
+
case 50:
|
|
149
|
+
_context.t2 = _context.sent;
|
|
150
|
+
workspacePackageJson = _context.t1.parse.call(_context.t1, _context.t2);
|
|
151
|
+
workspacePackageJson.name = toValidPackageName(name);
|
|
152
|
+
|
|
153
|
+
if (!(packageManager === 'pnpm')) {
|
|
154
|
+
_context.next = 62;
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
_context.t3 = outputRoot;
|
|
159
|
+
_context.next = 57;
|
|
160
|
+
return format("\n packages:\n - './packages/*'\n ", {
|
|
161
|
+
as: 'yaml'
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
case 57:
|
|
165
|
+
_context.t4 = _context.sent;
|
|
166
|
+
_context.next = 60;
|
|
167
|
+
return _context.t3.write.call(_context.t3, 'pnpm-workspace.yaml', _context.t4);
|
|
168
|
+
|
|
169
|
+
case 60:
|
|
170
|
+
_context.next = 63;
|
|
171
|
+
break;
|
|
172
|
+
|
|
173
|
+
case 62:
|
|
174
|
+
workspacePackageJson.workspaces = ['packages/*'];
|
|
175
|
+
|
|
176
|
+
case 63:
|
|
177
|
+
_context.t5 = outputRoot;
|
|
178
|
+
_context.next = 66;
|
|
179
|
+
return format(JSON.stringify(workspacePackageJson), {
|
|
180
|
+
as: 'json-stringify'
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
case 66:
|
|
184
|
+
_context.t6 = _context.sent;
|
|
185
|
+
_context.next = 69;
|
|
186
|
+
return _context.t5.write.call(_context.t5, 'package.json', _context.t6);
|
|
187
|
+
|
|
188
|
+
case 69:
|
|
189
|
+
_context.next = 103;
|
|
190
|
+
break;
|
|
191
|
+
|
|
192
|
+
case 71:
|
|
193
|
+
_context.next = 73;
|
|
194
|
+
return Promise.all([appTemplate.read('package.json').then(function (content) {
|
|
195
|
+
return JSON.parse(content);
|
|
196
|
+
}), appTemplate.read('tsconfig.json').then(function (content) {
|
|
197
|
+
return JSON.parse(content);
|
|
198
|
+
}), workspaceTemplate.read('package.json').then(function (content) {
|
|
199
|
+
return JSON.parse(content);
|
|
200
|
+
})]);
|
|
201
|
+
|
|
202
|
+
case 73:
|
|
203
|
+
_yield$Promise$all = _context.sent;
|
|
204
|
+
_yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 3);
|
|
205
|
+
projectPackageJson = _yield$Promise$all2[0];
|
|
206
|
+
projectTSConfig = _yield$Promise$all2[1];
|
|
207
|
+
_workspacePackageJson = _yield$Promise$all2[2];
|
|
208
|
+
_workspacePackageJson.name = toValidPackageName(name);
|
|
209
|
+
_workspacePackageJson.eslintConfig = projectPackageJson.eslintConfig;
|
|
210
|
+
_workspacePackageJson.browserslist = projectPackageJson.browserslist;
|
|
211
|
+
_context.next = 83;
|
|
212
|
+
return appTemplate.read('quilt.project.ts');
|
|
213
|
+
|
|
214
|
+
case 83:
|
|
215
|
+
quiltProject = _context.sent;
|
|
216
|
+
quiltProject = quiltProject.replace('quiltApp', 'quiltWorkspace, quiltApp').replace('quiltApp(', 'quiltWorkspace(), quiltApp(');
|
|
217
|
+
_context.t7 = outputRoot;
|
|
218
|
+
_context.next = 88;
|
|
219
|
+
return format(quiltProject, {
|
|
220
|
+
as: 'typescript'
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
case 88:
|
|
224
|
+
_context.t8 = _context.sent;
|
|
225
|
+
_context.next = 91;
|
|
226
|
+
return _context.t7.write.call(_context.t7, 'quilt.project.ts', _context.t8);
|
|
227
|
+
|
|
228
|
+
case 91:
|
|
229
|
+
_context.t9 = outputRoot;
|
|
230
|
+
_context.next = 94;
|
|
231
|
+
return format(JSON.stringify(_workspacePackageJson), {
|
|
232
|
+
as: 'json-stringify'
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
case 94:
|
|
236
|
+
_context.t10 = _context.sent;
|
|
237
|
+
_context.next = 97;
|
|
238
|
+
return _context.t9.write.call(_context.t9, 'package.json', _context.t10);
|
|
239
|
+
|
|
240
|
+
case 97:
|
|
241
|
+
_context.t11 = outputRoot;
|
|
242
|
+
_context.next = 100;
|
|
243
|
+
return format(JSON.stringify(projectTSConfig), {
|
|
244
|
+
as: 'json'
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
case 100:
|
|
248
|
+
_context.t12 = _context.sent;
|
|
249
|
+
_context.next = 103;
|
|
250
|
+
return _context.t11.write.call(_context.t11, 'tsconfig.json', _context.t12);
|
|
251
|
+
|
|
252
|
+
case 103:
|
|
253
|
+
if (!setupExtras.has('github')) {
|
|
254
|
+
_context.next = 106;
|
|
255
|
+
break;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
_context.next = 106;
|
|
259
|
+
return loadTemplate('github').copy(directory);
|
|
260
|
+
|
|
261
|
+
case 106:
|
|
262
|
+
if (!setupExtras.has('vscode')) {
|
|
263
|
+
_context.next = 109;
|
|
264
|
+
break;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
_context.next = 109;
|
|
268
|
+
return loadTemplate('vscode').copy(directory);
|
|
269
|
+
|
|
270
|
+
case 109:
|
|
271
|
+
_context.next = 111;
|
|
272
|
+
return appTemplate.copy(appDirectory, function (file) {
|
|
273
|
+
// If we are in a monorepo, we can use all the template files as they are
|
|
274
|
+
if (file === 'quilt.project.ts' || file === 'tsconfig.json') {
|
|
275
|
+
return partOfMonorepo;
|
|
276
|
+
} // We need to make some adjustments the project’s package.json
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
return file !== 'package.json';
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
case 111:
|
|
283
|
+
if (!partOfMonorepo) {
|
|
284
|
+
_context.next = 127;
|
|
285
|
+
break;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
_context.t13 = JSON;
|
|
289
|
+
_context.next = 115;
|
|
290
|
+
return appTemplate.read('package.json');
|
|
291
|
+
|
|
292
|
+
case 115:
|
|
293
|
+
_context.t14 = _context.sent;
|
|
294
|
+
_projectPackageJson = _context.t13.parse.call(_context.t13, _context.t14);
|
|
295
|
+
_projectPackageJson.name = path.basename(appDirectory);
|
|
296
|
+
_context.t15 = outputRoot;
|
|
297
|
+
_context.t16 = path.join(appDirectory, 'package.json');
|
|
298
|
+
_context.next = 122;
|
|
299
|
+
return format(JSON.stringify(_projectPackageJson), {
|
|
300
|
+
as: 'json-stringify'
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
case 122:
|
|
304
|
+
_context.t17 = _context.sent;
|
|
305
|
+
_context.next = 125;
|
|
306
|
+
return _context.t15.write.call(_context.t15, _context.t16, _context.t17);
|
|
307
|
+
|
|
308
|
+
case 125:
|
|
309
|
+
_context.next = 127;
|
|
310
|
+
return Promise.all([addToTsConfig(appDirectory, outputRoot), addToPackageManagerWorkspaces(appDirectory, outputRoot, packageManager)]);
|
|
311
|
+
|
|
312
|
+
case 127:
|
|
313
|
+
if (shouldInstall) {
|
|
314
|
+
process.stdout.write('\nInstalling dependencies...\n'); // TODO: better loading, handle errors
|
|
315
|
+
|
|
316
|
+
execSync("".concat(packageManager, " install"), {
|
|
317
|
+
cwd: rootDirectory
|
|
318
|
+
});
|
|
319
|
+
process.stdout.moveCursor(0, -1);
|
|
320
|
+
process.stdout.clearLine(1);
|
|
321
|
+
console.log('Installed dependencies.');
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
commands = [];
|
|
325
|
+
|
|
326
|
+
if (!inWorkspace && directory !== process.cwd()) {
|
|
327
|
+
commands.push("cd ".concat(cyan_1(relativeDirectoryForDisplay(path.relative(process.cwd(), directory))), " ").concat(dim_1('# Move into your new app’s directory')));
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
if (!shouldInstall) {
|
|
331
|
+
commands.push("pnpm install ".concat(dim_1('# Install all your dependencies')));
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
if (!inWorkspace) {
|
|
335
|
+
// TODO: change this condition to check if git was initialized already
|
|
336
|
+
commands.push("git init && git add -A && git commit -m \"Initial commit\" ".concat(dim_1('# Start your git history (optional)')));
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
commands.push("pnpm develop ".concat(dim_1('# Start the development server')));
|
|
340
|
+
whatsNext = stripIndent(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n Your new app is ready to go! There\u2019s just ", " you\u2019ll need to take\n in order to start developing:\n "])), commands.length > 1 ? 'a few more steps' : 'one more step');
|
|
341
|
+
console.log();
|
|
342
|
+
console.log(whatsNext);
|
|
343
|
+
console.log();
|
|
344
|
+
console.log(commands.map(function (command) {
|
|
345
|
+
return " ".concat(command);
|
|
346
|
+
}).join('\n'));
|
|
347
|
+
followUp = stripIndent(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n Quilt can also help you build, test, lint, and type-check your new application.\n You can learn more about building apps with Quilt by reading the documentation:\n ", "\n\n Have fun! \uD83C\uDF89\n "])), underline_1(magenta_1('https://github.com/lemonmade/quilt/tree/main/documentation')));
|
|
348
|
+
console.log();
|
|
349
|
+
console.log(followUp);
|
|
350
|
+
|
|
351
|
+
case 141:
|
|
352
|
+
case "end":
|
|
353
|
+
return _context.stop();
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
}, _callee);
|
|
357
|
+
}));
|
|
358
|
+
return _createApp.apply(this, arguments);
|
|
359
|
+
}
|
|
360
|
+
|
|
188
361
|
function getArgv() {
|
|
189
|
-
|
|
362
|
+
var argv = arg_1({
|
|
190
363
|
'--yes': Boolean,
|
|
191
364
|
'-y': '--yes',
|
|
192
365
|
'--name': String,
|
|
@@ -207,72 +380,188 @@ function getArgv() {
|
|
|
207
380
|
return argv;
|
|
208
381
|
}
|
|
209
382
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
}) {
|
|
213
|
-
let {
|
|
214
|
-
'--name': name
|
|
215
|
-
} = argv;
|
|
216
|
-
|
|
217
|
-
if (name == null) {
|
|
218
|
-
name = await prompt({
|
|
219
|
-
type: 'text',
|
|
220
|
-
message: 'What would you like to name your new app?',
|
|
221
|
-
initial: inWorkspace ? 'app' : 'my-quilt-app'
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
return name;
|
|
383
|
+
function getName(_x, _x2) {
|
|
384
|
+
return _getName.apply(this, arguments);
|
|
226
385
|
}
|
|
227
386
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
387
|
+
function _getName() {
|
|
388
|
+
_getName = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(argv, _ref) {
|
|
389
|
+
var inWorkspace, name;
|
|
390
|
+
return regenerator.wrap(function _callee2$(_context2) {
|
|
391
|
+
while (1) {
|
|
392
|
+
switch (_context2.prev = _context2.next) {
|
|
393
|
+
case 0:
|
|
394
|
+
inWorkspace = _ref.inWorkspace;
|
|
395
|
+
name = argv['--name'];
|
|
396
|
+
|
|
397
|
+
if (!(name == null)) {
|
|
398
|
+
_context2.next = 6;
|
|
399
|
+
break;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
_context2.next = 5;
|
|
403
|
+
return prompt({
|
|
404
|
+
type: 'text',
|
|
405
|
+
message: 'What would you like to name your new app?',
|
|
406
|
+
initial: inWorkspace ? 'app' : 'my-quilt-app'
|
|
407
|
+
});
|
|
408
|
+
|
|
409
|
+
case 5:
|
|
410
|
+
name = _context2.sent;
|
|
411
|
+
|
|
412
|
+
case 6:
|
|
413
|
+
return _context2.abrupt("return", name);
|
|
414
|
+
|
|
415
|
+
case 7:
|
|
416
|
+
case "end":
|
|
417
|
+
return _context2.stop();
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
}, _callee2);
|
|
421
|
+
}));
|
|
422
|
+
return _getName.apply(this, arguments);
|
|
253
423
|
}
|
|
254
424
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
425
|
+
function getDirectory(_x3, _x4) {
|
|
426
|
+
return _getDirectory.apply(this, arguments);
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
function _getDirectory() {
|
|
430
|
+
_getDirectory = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(argv, _ref2) {
|
|
431
|
+
var _argv$Directory;
|
|
432
|
+
|
|
433
|
+
var name, directory, relativeDirectory, empty, promptDirectory;
|
|
434
|
+
return regenerator.wrap(function _callee3$(_context3) {
|
|
435
|
+
while (1) {
|
|
436
|
+
switch (_context3.prev = _context3.next) {
|
|
437
|
+
case 0:
|
|
438
|
+
name = _ref2.name;
|
|
439
|
+
directory = path.resolve((_argv$Directory = argv['--directory']) !== null && _argv$Directory !== void 0 ? _argv$Directory : toValidPackageName(name));
|
|
440
|
+
|
|
441
|
+
case 2:
|
|
442
|
+
if (argv['--yes']) {
|
|
443
|
+
_context3.next = 24;
|
|
444
|
+
break;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
_context3.t0 = fs.existsSync(directory);
|
|
448
|
+
|
|
449
|
+
if (!_context3.t0) {
|
|
450
|
+
_context3.next = 8;
|
|
451
|
+
break;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
_context3.next = 7;
|
|
455
|
+
return isEmpty(directory);
|
|
456
|
+
|
|
457
|
+
case 7:
|
|
458
|
+
_context3.t0 = !_context3.sent;
|
|
459
|
+
|
|
460
|
+
case 8:
|
|
461
|
+
if (!_context3.t0) {
|
|
462
|
+
_context3.next = 21;
|
|
463
|
+
break;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
relativeDirectory = path.relative(process.cwd(), directory);
|
|
467
|
+
_context3.next = 12;
|
|
468
|
+
return prompt({
|
|
469
|
+
type: 'confirm',
|
|
470
|
+
message: "Directory ".concat(bold_1(relativeDirectoryForDisplay(relativeDirectory)), " is not empty, is it safe to empty it?"),
|
|
471
|
+
initial: true
|
|
472
|
+
});
|
|
473
|
+
|
|
474
|
+
case 12:
|
|
475
|
+
empty = _context3.sent;
|
|
476
|
+
|
|
477
|
+
if (!empty) {
|
|
478
|
+
_context3.next = 15;
|
|
479
|
+
break;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
return _context3.abrupt("break", 24);
|
|
483
|
+
|
|
484
|
+
case 15:
|
|
485
|
+
_context3.next = 17;
|
|
486
|
+
return prompt({
|
|
487
|
+
type: 'text',
|
|
488
|
+
message: 'What directory do you want to create your new app in?'
|
|
489
|
+
});
|
|
490
|
+
|
|
491
|
+
case 17:
|
|
492
|
+
promptDirectory = _context3.sent;
|
|
493
|
+
directory = path.resolve(promptDirectory);
|
|
494
|
+
_context3.next = 22;
|
|
495
|
+
break;
|
|
496
|
+
|
|
497
|
+
case 21:
|
|
498
|
+
return _context3.abrupt("break", 24);
|
|
499
|
+
|
|
500
|
+
case 22:
|
|
501
|
+
_context3.next = 2;
|
|
502
|
+
break;
|
|
503
|
+
|
|
504
|
+
case 24:
|
|
505
|
+
return _context3.abrupt("return", directory);
|
|
506
|
+
|
|
507
|
+
case 25:
|
|
508
|
+
case "end":
|
|
509
|
+
return _context3.stop();
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
}, _callee3);
|
|
513
|
+
}));
|
|
514
|
+
return _getDirectory.apply(this, arguments);
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
var VALID_TEMPLATES = new Set(['basic', 'single-file']);
|
|
518
|
+
|
|
519
|
+
function getTemplate(_x5) {
|
|
520
|
+
return _getTemplate.apply(this, arguments);
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
function _getTemplate() {
|
|
524
|
+
_getTemplate = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(argv) {
|
|
525
|
+
var template;
|
|
526
|
+
return regenerator.wrap(function _callee4$(_context4) {
|
|
527
|
+
while (1) {
|
|
528
|
+
switch (_context4.prev = _context4.next) {
|
|
529
|
+
case 0:
|
|
530
|
+
if (!(argv['--template'] && VALID_TEMPLATES.has(argv['--template']))) {
|
|
531
|
+
_context4.next = 2;
|
|
532
|
+
break;
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
return _context4.abrupt("return", argv['--template']);
|
|
536
|
+
|
|
537
|
+
case 2:
|
|
538
|
+
_context4.next = 4;
|
|
539
|
+
return prompt({
|
|
540
|
+
type: 'select',
|
|
541
|
+
message: 'What template would you like to use?',
|
|
542
|
+
hint: "Use ".concat(bold_1('arrow keys'), " to select, and ").concat(bold_1('return'), " to submit"),
|
|
543
|
+
choices: [{
|
|
544
|
+
title: "".concat(bold_1('The basics'), ", a web app with a minimal file structure"),
|
|
545
|
+
value: 'basic'
|
|
546
|
+
}, {
|
|
547
|
+
title: "".concat(bold_1('Itty-bitty'), ", an entire web app in a single file"),
|
|
548
|
+
value: 'single-file'
|
|
549
|
+
} // TODO: GraphQL API
|
|
550
|
+
]
|
|
551
|
+
});
|
|
552
|
+
|
|
553
|
+
case 4:
|
|
554
|
+
template = _context4.sent;
|
|
555
|
+
return _context4.abrupt("return", template);
|
|
556
|
+
|
|
557
|
+
case 6:
|
|
558
|
+
case "end":
|
|
559
|
+
return _context4.stop();
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
}, _callee4);
|
|
563
|
+
}));
|
|
564
|
+
return _getTemplate.apply(this, arguments);
|
|
276
565
|
}
|
|
277
566
|
|
|
278
567
|
export { createApp };
|