@quilted/create 0.1.17 → 0.1.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +30 -0
  3. package/build/tsconfig.tsbuildinfo +1 -1
  4. package/build/typescript/app.d.ts.map +1 -1
  5. package/build/typescript/package.d.ts +1 -1
  6. package/build/typescript/package.d.ts.map +1 -1
  7. package/package.json +5 -3
  8. package/quilt.project.ts +19 -5
  9. package/source/app.ts +0 -10
  10. package/source/create.ts +2 -2
  11. package/source/package.ts +6 -11
  12. package/templates/app-basic/features/Start/Start.test.tsx +12 -0
  13. package/templates/app-basic/foundation/Head/Head.test.tsx +25 -0
  14. package/templates/app-basic/foundation/{Head.tsx → Head/Head.tsx} +0 -0
  15. package/templates/app-basic/foundation/Head/index.ts +1 -0
  16. package/templates/app-basic/foundation/Http/Http.test.tsx +24 -0
  17. package/templates/app-basic/foundation/{Http.tsx → Http/Http.tsx} +0 -0
  18. package/templates/app-basic/foundation/Http/index.ts +1 -0
  19. package/templates/app-basic/quilt.project.ts +5 -5
  20. package/templates/app-basic/tests/mount.tsx +47 -0
  21. package/templates/app-basic/tsconfig.json +4 -3
  22. package/templates/app-single-file/quilt.project.ts +3 -4
  23. package/templates/app-single-file/tsconfig.json +2 -2
  24. package/templates/package/package.json +4 -2
  25. package/templates/package/quilt.project.ts +3 -4
  26. package/templates/package/source/index.ts +3 -1
  27. package/templates/package/source/tests/index.test.ts +8 -0
  28. package/templates/package/tsconfig.json +2 -2
  29. package/templates/workspace/package.json +1 -1
  30. package/tsconfig.json +1 -1
  31. package/bin/create-quilt.mjs +0 -2
  32. package/build/cjs/_commonjsHelpers.cjs +0 -10
  33. package/build/cjs/app.cjs +0 -303
  34. package/build/cjs/index.cjs +0 -6784
  35. package/build/cjs/index2.cjs +0 -374
  36. package/build/cjs/index3.cjs +0 -7854
  37. package/build/cjs/minimatch.cjs +0 -1202
  38. package/build/cjs/package-manager.cjs +0 -305
  39. package/build/cjs/package.cjs +0 -424
  40. package/build/cjs/parser-babel.cjs +0 -59
  41. package/build/cjs/parser-yaml.cjs +0 -182
  42. package/build/cjs/standalone.cjs +0 -147
  43. package/build/esm/_commonjsHelpers.mjs +0 -7
  44. package/build/esm/app.mjs +0 -280
  45. package/build/esm/index.mjs +0 -6743
  46. package/build/esm/index2.mjs +0 -365
  47. package/build/esm/index3.mjs +0 -7852
  48. package/build/esm/minimatch.mjs +0 -1200
  49. package/build/esm/package-manager.mjs +0 -275
  50. package/build/esm/package.mjs +0 -401
  51. package/build/esm/parser-babel.mjs +0 -57
  52. package/build/esm/parser-yaml.mjs +0 -180
  53. package/build/esm/standalone.mjs +0 -145
@@ -1,305 +0,0 @@
1
- 'use strict';
2
-
3
- var path = require('path');
4
- var fs = require('fs');
5
- var url = require('url');
6
- require('./index.cjs');
7
-
8
- function _interopNamespace(e) {
9
- if (e && e.__esModule) return e;
10
- var n = Object.create(null);
11
- if (e) {
12
- Object.keys(e).forEach(function (k) {
13
- if (k !== 'default') {
14
- var d = Object.getOwnPropertyDescriptor(e, k);
15
- Object.defineProperty(n, k, d.get ? d : {
16
- enumerable: true,
17
- get: function () { return e[k]; }
18
- });
19
- }
20
- });
21
- }
22
- n["default"] = e;
23
- return Object.freeze(n);
24
- }
25
-
26
- var path__namespace = /*#__PURE__*/_interopNamespace(path);
27
- var fs__namespace = /*#__PURE__*/_interopNamespace(fs);
28
-
29
- function loadTemplate(name) {
30
- let templateRootPromise;
31
- return {
32
- async copy(to, handleFile) {
33
- templateRootPromise ?? (templateRootPromise = templateDirectory(name));
34
- const templateRoot = await templateRootPromise;
35
- const targetRoot = path__namespace.resolve(to);
36
- const files = fs__namespace.readdirSync(templateRoot).filter(file => !path__namespace.basename(file).startsWith('.'));
37
-
38
- for (const file of files) {
39
- if (handleFile) {
40
- if (!handleFile(file)) {
41
- continue;
42
- }
43
- }
44
-
45
- const targetPath = path__namespace.join(targetRoot, file.startsWith('_') ? `.${file.slice(1)}` : file);
46
- copy(path__namespace.join(templateRoot, file), targetPath);
47
- }
48
- },
49
-
50
- async read(file) {
51
- templateRootPromise ?? (templateRootPromise = templateDirectory(name));
52
- const templateRoot = await templateRootPromise;
53
- return fs__namespace.readFileSync(path__namespace.join(templateRoot, file), {
54
- encoding: 'utf8'
55
- });
56
- }
57
-
58
- };
59
- }
60
- function createOutputTarget(target) {
61
- return {
62
- root: target,
63
-
64
- read(file) {
65
- return fs__namespace.promises.readFile(path__namespace.resolve(target, file), {
66
- encoding: 'utf8'
67
- });
68
- },
69
-
70
- async write(file, content) {
71
- await writeFile(path__namespace.resolve(target, file), content);
72
- }
73
-
74
- };
75
- }
76
- let packageRootPromise;
77
-
78
- async function templateDirectory(name) {
79
- return path__namespace.join(await getPackageRoot(), 'templates', name);
80
- }
81
-
82
- async function getPackageRoot() {
83
- if (!packageRootPromise) {
84
- packageRootPromise = (async () => {
85
- const {
86
- packageDirectory
87
- } = await Promise.resolve().then(function () { return require('./index2.cjs'); });
88
- return packageDirectory({
89
- cwd: path__namespace.dirname(url.fileURLToPath((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('package-manager.cjs', document.baseURI).href))))
90
- });
91
- })();
92
- }
93
-
94
- return packageRootPromise;
95
- }
96
-
97
- function toValidPackageName(projectName) {
98
- return projectName.trim().toLowerCase().replace(/\s+/g, '-').replace(/^[._]/, '').replace(/[^a-z0-9-~@/]+/g, '-');
99
- }
100
-
101
- function copy(source, destination) {
102
- const stat = fs__namespace.statSync(source);
103
-
104
- if (stat.isDirectory()) {
105
- copyDirectory(source, destination);
106
- } else {
107
- fs__namespace.copyFileSync(source, destination);
108
- }
109
- }
110
-
111
- async function copyDirectory(source, destination) {
112
- fs__namespace.mkdirSync(destination, {
113
- recursive: true
114
- });
115
-
116
- for (const file of fs__namespace.readdirSync(source)) {
117
- const srcFile = path__namespace.resolve(source, file);
118
- const destFile = path__namespace.resolve(destination, file);
119
- copy(srcFile, destFile);
120
- }
121
- }
122
-
123
- async function writeFile(file, content) {
124
- await fs__namespace.promises.writeFile(file, content);
125
- }
126
- async function isEmpty(path) {
127
- return fs__namespace.readdirSync(path).length === 0;
128
- }
129
- async function emptyDirectory(dir) {
130
- if (!fs__namespace.existsSync(dir)) {
131
- return;
132
- }
133
-
134
- for (const file of fs__namespace.readdirSync(dir)) {
135
- fs__namespace.rmSync(path__namespace.resolve(dir, file), {
136
- force: true,
137
- recursive: true
138
- });
139
- }
140
- }
141
- function relativeDirectoryForDisplay(relativeDirectory) {
142
- return relativeDirectory.startsWith('.') ? relativeDirectory : `.${path__namespace.sep}${relativeDirectory}`;
143
- }
144
- async function format(content, {
145
- as: parser
146
- }) {
147
- const [{
148
- format
149
- }, {
150
- default: babel
151
- }, {
152
- default: yaml
153
- }] = await Promise.all([Promise.resolve().then(function () { return require('./standalone.cjs'); }).then(function (n) { return n.standalone; }), Promise.resolve().then(function () { return require('./parser-babel.cjs'); }).then(function (n) { return n.parserBabel; }), Promise.resolve().then(function () { return require('./parser-yaml.cjs'); }).then(function (n) { return n.parserYaml; })]);
154
- return format(content, {
155
- arrowParens: 'always',
156
- bracketSpacing: false,
157
- singleQuote: true,
158
- trailingComma: 'all',
159
- parser,
160
- plugins: [babel, yaml]
161
- });
162
- }
163
-
164
- const ENDS_WITH_TSCONFIG = /[/]?tsconfig[.a-z0-9]*[.]json/i;
165
- async function addToTsConfig(directory, output) {
166
- const tsconfig = JSON.parse(await output.read('tsconfig.json'));
167
- tsconfig.references ?? (tsconfig.references = []);
168
- const relativePath = path.relative(output.root, directory);
169
- const relativeForDisplay = relativeDirectoryForDisplay(relativePath);
170
-
171
- if (tsconfig.references.length === 0) {
172
- tsconfig.references.push({
173
- path: relativeForDisplay
174
- });
175
- } else {
176
- let hasExistingReference = false;
177
- let referenceFormat = 'pretty-relative';
178
-
179
- for (const {
180
- path
181
- } of tsconfig.references) {
182
- if (path.startsWith('./')) {
183
- if (ENDS_WITH_TSCONFIG.test(path)) {
184
- referenceFormat = 'pretty-tsconfig';
185
-
186
- if (path === `${relativeForDisplay}/tsconfig.json`) {
187
- hasExistingReference = true;
188
- break;
189
- }
190
- }
191
-
192
- referenceFormat = 'pretty-relative';
193
-
194
- if (path === relativeForDisplay) {
195
- hasExistingReference = true;
196
- break;
197
- }
198
- } else if (ENDS_WITH_TSCONFIG.test(path)) {
199
- referenceFormat = 'tsconfig';
200
-
201
- if (path === `${relativePath}/tsconfig.json`) {
202
- hasExistingReference = true;
203
- break;
204
- }
205
- } else {
206
- referenceFormat = 'relative';
207
-
208
- if (path === relativePath) {
209
- hasExistingReference = true;
210
- break;
211
- }
212
- }
213
- }
214
-
215
- if (!hasExistingReference) {
216
- let path;
217
-
218
- if (referenceFormat === 'pretty-tsconfig') {
219
- path = `${relativeForDisplay}/tsconfig.json`;
220
- } else if (referenceFormat === 'pretty-relative') {
221
- path = relativeForDisplay;
222
- } else if (referenceFormat === 'tsconfig') {
223
- path = `${relativePath}/tsconfig.json`;
224
- } else {
225
- path = relativePath;
226
- }
227
-
228
- tsconfig.references.push({
229
- path
230
- });
231
- }
232
- }
233
-
234
- tsconfig.references = tsconfig.references.sort(({
235
- path: pathOne
236
- }, {
237
- path: pathTwo
238
- }) => pathOne.localeCompare(pathTwo));
239
- await output.write('tsconfig.json', await format(JSON.stringify(tsconfig), {
240
- as: 'json'
241
- }));
242
- }
243
-
244
- async function addToPackageManagerWorkspaces(directory, output, packageManager) {
245
- if (packageManager === 'pnpm') {
246
- const {
247
- parse,
248
- stringify
249
- } = await Promise.resolve().then(function () { return require('./index3.cjs'); }).then(function (n) { return n.index; });
250
- const workspaceYaml = parse(await output.read('pnpm-workspace.yaml'));
251
- workspaceYaml.packages = await addToWorkspaces(path.relative(output.root, directory), workspaceYaml.packages ?? []);
252
- await output.write('pnpm-workspace.yaml', await format(stringify(workspaceYaml), {
253
- as: 'yaml'
254
- }));
255
- } else {
256
- const packageJson = JSON.parse(await output.read('package.json'));
257
- packageJson.workspaces = await addToWorkspaces(path.relative(output.root, directory), packageJson.workspaces ?? []);
258
- await output.write('package.json', await format(JSON.stringify(packageJson), {
259
- as: 'json-stringify'
260
- }));
261
- }
262
- }
263
-
264
- async function addToWorkspaces(relative, workspaces) {
265
- if (workspaces.length === 0) {
266
- return [relative];
267
- } // Default documentation seems to generally exclude leading `./` on paths
268
-
269
-
270
- let pretty = false;
271
- let hasMatch = false;
272
- const {
273
- default: minimatch
274
- } = await Promise.resolve().then(function () { return require('./minimatch.cjs'); }).then(function (n) { return n.minimatch; });
275
-
276
- for (const pattern of workspaces) {
277
- let normalizedPattern = pattern;
278
-
279
- if (pattern.startsWith('./')) {
280
- pretty = true;
281
- normalizedPattern = pattern.slice(2);
282
- }
283
-
284
- if (minimatch(relative, normalizedPattern)) {
285
- hasMatch = true;
286
- break;
287
- }
288
- }
289
-
290
- if (hasMatch) {
291
- return workspaces;
292
- }
293
-
294
- return [...workspaces, pretty ? relativeDirectoryForDisplay(relative) : relative].sort((patternOne, patternTwo) => patternOne.localeCompare(patternTwo));
295
- }
296
-
297
- exports.addToPackageManagerWorkspaces = addToPackageManagerWorkspaces;
298
- exports.addToTsConfig = addToTsConfig;
299
- exports.createOutputTarget = createOutputTarget;
300
- exports.emptyDirectory = emptyDirectory;
301
- exports.format = format;
302
- exports.isEmpty = isEmpty;
303
- exports.loadTemplate = loadTemplate;
304
- exports.relativeDirectoryForDisplay = relativeDirectoryForDisplay;
305
- exports.toValidPackageName = toValidPackageName;