skeleton 1.0.0 → 1.0.1-next.1
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/README.md +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1136 -0
- package/dist/index.js.map +1 -0
- package/package.json +32 -29
- package/dist/index.d.mts +0 -6
- package/dist/index.mjs +0 -1164
package/dist/index.mjs
DELETED
|
@@ -1,1164 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { multiselect, isCancel, spinner, log, outro, intro } from '@clack/prompts';
|
|
3
|
-
import { glob } from 'tinyglobby';
|
|
4
|
-
import { coerce, lt } from 'semver';
|
|
5
|
-
import detectIndent from 'detect-indent';
|
|
6
|
-
import { red, dim, bgBlueBright, black, bgGreenBright } from 'colorette';
|
|
7
|
-
import { Command, Argument, Option } from 'commander';
|
|
8
|
-
import { fileURLToPath } from 'node:url';
|
|
9
|
-
import { extname, join, dirname } from 'node:path';
|
|
10
|
-
import { readFile, writeFile } from 'node:fs/promises';
|
|
11
|
-
import { parse as parse$1 } from 'svelte/compiler';
|
|
12
|
-
import { walk } from 'zimmerframe';
|
|
13
|
-
import MagicString from 'magic-string';
|
|
14
|
-
import { Project, Node } from 'ts-morph';
|
|
15
|
-
import { nanoid } from 'nanoid';
|
|
16
|
-
import { parse, atRule, comment } from 'postcss';
|
|
17
|
-
import { detect, resolveCommand } from 'package-manager-detector';
|
|
18
|
-
import child_process from 'node:child_process';
|
|
19
|
-
import { promisify } from 'node:util';
|
|
20
|
-
import getLatestVersion from 'latest-version';
|
|
21
|
-
import { parse as parse$2 } from 'node-html-parser';
|
|
22
|
-
|
|
23
|
-
function sortPropertiesAlphabetically(object) {
|
|
24
|
-
const orderedObject = {};
|
|
25
|
-
const sortedEntries = Object.entries(object).sort(([a], [b]) => a.localeCompare(b));
|
|
26
|
-
for (const [key, value] of sortedEntries) {
|
|
27
|
-
orderedObject[key] = value;
|
|
28
|
-
}
|
|
29
|
-
return orderedObject;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function transformPackageJson(code, skeletonVersion, skeletonSvelteVersion) {
|
|
33
|
-
let isUsingComponents = false;
|
|
34
|
-
const pkg = JSON.parse(code);
|
|
35
|
-
for (const field of ["dependencies", "devDependencies"]) {
|
|
36
|
-
if (!pkg[field]) {
|
|
37
|
-
continue;
|
|
38
|
-
}
|
|
39
|
-
const coerced = coerce(pkg[field]["@skeletonlabs/skeleton"]);
|
|
40
|
-
if (coerced && lt(coerced.version, "3.0.0")) {
|
|
41
|
-
isUsingComponents = true;
|
|
42
|
-
delete pkg[field]["@skeletonlabs/skeleton"];
|
|
43
|
-
pkg[field]["@skeletonlabs/skeleton-svelte"] = `^${skeletonSvelteVersion}`;
|
|
44
|
-
}
|
|
45
|
-
if (pkg[field]["@skeletonlabs/tw-plugin"]) {
|
|
46
|
-
delete pkg[field]["@skeletonlabs/tw-plugin"];
|
|
47
|
-
pkg[field]["@skeletonlabs/skeleton"] = `^${skeletonVersion}`;
|
|
48
|
-
}
|
|
49
|
-
pkg[field] = sortPropertiesAlphabetically(pkg[field]);
|
|
50
|
-
}
|
|
51
|
-
return {
|
|
52
|
-
code: JSON.stringify(pkg, null, detectIndent(code).indent || " "),
|
|
53
|
-
meta: {
|
|
54
|
-
isUsingComponents
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const COLOR_PAIRING_REGEXES = [
|
|
60
|
-
{
|
|
61
|
-
find: /(\w+)-50-900-token\b/g,
|
|
62
|
-
replace: "$1-50-950"
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
find: /(\w+)-100-800-token\b/g,
|
|
66
|
-
replace: "$1-100-900"
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
find: /(\w+)-200-700-token\b/g,
|
|
70
|
-
replace: "$1-200-800"
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
find: /(\w+)-300-600-token\b/g,
|
|
74
|
-
replace: "$1-300-700"
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
find: /(\w+)-400-500-token\b/g,
|
|
78
|
-
replace: "$1-500"
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
find: /(\w+)-900-50-token\b/g,
|
|
82
|
-
replace: "$1-950-50"
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
find: /(\w+)-800-100-token\b/g,
|
|
86
|
-
replace: "$1-900-100"
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
find: /(\w+)-700-200-token\b/g,
|
|
90
|
-
replace: "$1-800-200"
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
find: /(\w+)-600-300-token\b/g,
|
|
94
|
-
replace: "$1-700-300"
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
find: /(\w+)-500-400-token\b/g,
|
|
98
|
-
replace: "$1-600-400"
|
|
99
|
-
}
|
|
100
|
-
];
|
|
101
|
-
const BACKGROUND_REGEXES = [
|
|
102
|
-
{
|
|
103
|
-
find: /bg-(\w+)-backdrop-token\b/g,
|
|
104
|
-
replace: "bg-$1-50/50 dark:bg-$1-950/50"
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
find: /bg-(\w+)-hover-token\b/g,
|
|
108
|
-
replace: "preset-tonal-$1"
|
|
109
|
-
},
|
|
110
|
-
{
|
|
111
|
-
find: /bg-(\w+)-active-token\b/g,
|
|
112
|
-
replace: "preset-filled-$1-500"
|
|
113
|
-
}
|
|
114
|
-
];
|
|
115
|
-
const BORDER_RADIUS_REGEXES = [
|
|
116
|
-
{
|
|
117
|
-
find: /rounded-token\b/g,
|
|
118
|
-
replace: "rounded-base"
|
|
119
|
-
},
|
|
120
|
-
{
|
|
121
|
-
find: /rounded-(tl|tr|bl|br)-token\b/g,
|
|
122
|
-
replace: "rounded-$1-base"
|
|
123
|
-
},
|
|
124
|
-
{
|
|
125
|
-
find: /rounded-container-token\b/g,
|
|
126
|
-
replace: "rounded-container"
|
|
127
|
-
},
|
|
128
|
-
{
|
|
129
|
-
find: /rounded-(tl|tr|bl|br)-container-token\b/g,
|
|
130
|
-
replace: "rounded-$1-container"
|
|
131
|
-
}
|
|
132
|
-
];
|
|
133
|
-
const BORDER_RING_REGEXES = [
|
|
134
|
-
{
|
|
135
|
-
find: /border-token\b/g,
|
|
136
|
-
replace: "border"
|
|
137
|
-
},
|
|
138
|
-
{
|
|
139
|
-
find: /border-(\w+)-(\d+)-(\d+)-token\b/g,
|
|
140
|
-
replace: "border-$1-$2-$3"
|
|
141
|
-
},
|
|
142
|
-
{
|
|
143
|
-
find: /ring-token\b/g,
|
|
144
|
-
replace: "ring"
|
|
145
|
-
},
|
|
146
|
-
{
|
|
147
|
-
find: /ring-(\w+)-(\d+)-(\d+)-token\b/g,
|
|
148
|
-
replace: "ring-$1-$2-$3"
|
|
149
|
-
}
|
|
150
|
-
];
|
|
151
|
-
const TEXT_REGEXES = [
|
|
152
|
-
{
|
|
153
|
-
find: /font-headings-token\b/g,
|
|
154
|
-
replace: "heading-font-family"
|
|
155
|
-
},
|
|
156
|
-
{
|
|
157
|
-
find: /font-token\b/g,
|
|
158
|
-
replace: "base-font-family"
|
|
159
|
-
},
|
|
160
|
-
{
|
|
161
|
-
find: /text-token\b/g,
|
|
162
|
-
replace: "base-font-color"
|
|
163
|
-
},
|
|
164
|
-
{
|
|
165
|
-
find: /text-on-(\w+)-token\b/g,
|
|
166
|
-
replace: "text-$1-contrast-500"
|
|
167
|
-
},
|
|
168
|
-
{
|
|
169
|
-
find: /text-(\w+)-([^-]+)-([^-]+)-token\b/g,
|
|
170
|
-
replace: "text-$1-$2-$3"
|
|
171
|
-
}
|
|
172
|
-
];
|
|
173
|
-
const DECORATION_ACCENT_REGEXES = [
|
|
174
|
-
{
|
|
175
|
-
find: /decoration-(\w+)-([^-]+)-([^-]+)-token\b/g,
|
|
176
|
-
replace: "decoration-$1-$2-$3"
|
|
177
|
-
},
|
|
178
|
-
{
|
|
179
|
-
find: /accent-(\w+)-token\b/g,
|
|
180
|
-
replace: "accent-$1-500"
|
|
181
|
-
}
|
|
182
|
-
];
|
|
183
|
-
const PRESET_REGEXES = [
|
|
184
|
-
{
|
|
185
|
-
find: /variant-filled-(\w+)\b/g,
|
|
186
|
-
replace: "preset-filled-$1-500"
|
|
187
|
-
},
|
|
188
|
-
{
|
|
189
|
-
find: /variant-filled\b/g,
|
|
190
|
-
replace: "preset-filled"
|
|
191
|
-
},
|
|
192
|
-
{
|
|
193
|
-
find: /variant-ghost-(\w+)\b/g,
|
|
194
|
-
replace: "preset-tonal-$1 border border-$1-500"
|
|
195
|
-
},
|
|
196
|
-
{
|
|
197
|
-
find: /variant-ghost\b/g,
|
|
198
|
-
replace: "preset-tonal border border-surface-500"
|
|
199
|
-
},
|
|
200
|
-
{
|
|
201
|
-
find: /variant-soft-(\w+)\b/g,
|
|
202
|
-
replace: "preset-tonal-$1"
|
|
203
|
-
},
|
|
204
|
-
{
|
|
205
|
-
find: /variant-soft\b/g,
|
|
206
|
-
replace: "preset-tonal"
|
|
207
|
-
},
|
|
208
|
-
{
|
|
209
|
-
find: /variant-ringed-(\w+)\b/g,
|
|
210
|
-
replace: "preset-outlined-$1-500"
|
|
211
|
-
},
|
|
212
|
-
{
|
|
213
|
-
find: /variant-ringed\b/g,
|
|
214
|
-
replace: "preset-outlined"
|
|
215
|
-
},
|
|
216
|
-
{
|
|
217
|
-
find: /variant-glass-(\w+)\b/g,
|
|
218
|
-
replace: "preset-tonal-$1"
|
|
219
|
-
},
|
|
220
|
-
{
|
|
221
|
-
find: /variant-glass\b/g,
|
|
222
|
-
replace: "preset-tonal"
|
|
223
|
-
},
|
|
224
|
-
{
|
|
225
|
-
find: /variant-gradient-(\w+)-(\w+)\b/g,
|
|
226
|
-
replace: "from-$1-500 to-$2-500"
|
|
227
|
-
}
|
|
228
|
-
];
|
|
229
|
-
const TAILWIND_COMPONENT_REGEXES = [
|
|
230
|
-
/**
|
|
231
|
-
* Disabled until further discussion
|
|
232
|
-
* @see https://github.com/skeletonlabs/skeleton/pull/2972#discussion_r1857260763
|
|
233
|
-
*/
|
|
234
|
-
// {
|
|
235
|
-
// find: /\bcard\b(?!.*bg-)/g,
|
|
236
|
-
// replace: 'card bg-surface-100-900-token'
|
|
237
|
-
// },
|
|
238
|
-
{
|
|
239
|
-
find: /btn-xl\b/g,
|
|
240
|
-
replace: "btn-lg"
|
|
241
|
-
},
|
|
242
|
-
{
|
|
243
|
-
find: /btn-icon-xl\b/g,
|
|
244
|
-
replace: "btn-icon-lg"
|
|
245
|
-
},
|
|
246
|
-
{
|
|
247
|
-
find: /btn-group\b/g,
|
|
248
|
-
replace: ""
|
|
249
|
-
},
|
|
250
|
-
{
|
|
251
|
-
find: /table-hover\b/g,
|
|
252
|
-
replace: ""
|
|
253
|
-
}
|
|
254
|
-
];
|
|
255
|
-
const CLASS_REGEXES = [
|
|
256
|
-
...COLOR_PAIRING_REGEXES,
|
|
257
|
-
...BACKGROUND_REGEXES,
|
|
258
|
-
...BORDER_RADIUS_REGEXES,
|
|
259
|
-
...BORDER_RING_REGEXES,
|
|
260
|
-
...TEXT_REGEXES,
|
|
261
|
-
...DECORATION_ACCENT_REGEXES,
|
|
262
|
-
...PRESET_REGEXES,
|
|
263
|
-
...TAILWIND_COMPONENT_REGEXES
|
|
264
|
-
];
|
|
265
|
-
function transformClasses(code) {
|
|
266
|
-
return {
|
|
267
|
-
code: CLASS_REGEXES.reduce((result, migration) => {
|
|
268
|
-
return result.replace(migration.find, migration.replace);
|
|
269
|
-
}, code)
|
|
270
|
-
};
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
function addNamedImport(file, specifier, name) {
|
|
274
|
-
const existingImportDeclaration = file.getImportDeclaration((importDeclaration) => {
|
|
275
|
-
const moduleSpecifier = importDeclaration.getModuleSpecifier().getLiteralText();
|
|
276
|
-
return moduleSpecifier === specifier;
|
|
277
|
-
});
|
|
278
|
-
if (existingImportDeclaration) {
|
|
279
|
-
if (!existingImportDeclaration.getNamedImports().some((namedImport) => namedImport.getName() === name)) {
|
|
280
|
-
existingImportDeclaration.addNamedImport(name);
|
|
281
|
-
}
|
|
282
|
-
} else {
|
|
283
|
-
file.addImportDeclaration({
|
|
284
|
-
moduleSpecifier: specifier,
|
|
285
|
-
namedImports: [name]
|
|
286
|
-
});
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
const project = new Project({
|
|
291
|
-
useInMemoryFileSystem: true,
|
|
292
|
-
skipAddingFilesFromTsConfig: true,
|
|
293
|
-
skipFileDependencyResolution: true,
|
|
294
|
-
skipLoadingLibFiles: true
|
|
295
|
-
});
|
|
296
|
-
function parseSourceFile(code) {
|
|
297
|
-
return project.createSourceFile(`${nanoid()}.ts`, code);
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
const EXPORT_MAPPINGS = {
|
|
301
|
-
AccordionItem: {
|
|
302
|
-
namedImport: {
|
|
303
|
-
type: "renamed",
|
|
304
|
-
value: "Accordion"
|
|
305
|
-
},
|
|
306
|
-
identifier: {
|
|
307
|
-
type: "renamed",
|
|
308
|
-
value: "Accordion.Item"
|
|
309
|
-
}
|
|
310
|
-
},
|
|
311
|
-
AppShell: {
|
|
312
|
-
namedImport: {
|
|
313
|
-
type: "removed"
|
|
314
|
-
},
|
|
315
|
-
identifier: {
|
|
316
|
-
type: "removed"
|
|
317
|
-
}
|
|
318
|
-
},
|
|
319
|
-
Apollo: {
|
|
320
|
-
namedImport: { type: "removed" },
|
|
321
|
-
identifier: { type: "removed" }
|
|
322
|
-
},
|
|
323
|
-
AppRailAnchor: {
|
|
324
|
-
namedImport: { type: "removed" },
|
|
325
|
-
identifier: { type: "removed" }
|
|
326
|
-
},
|
|
327
|
-
Autocomplete: {
|
|
328
|
-
namedImport: { type: "removed" },
|
|
329
|
-
identifier: { type: "removed" }
|
|
330
|
-
},
|
|
331
|
-
BlueNight: {
|
|
332
|
-
namedImport: { type: "removed" },
|
|
333
|
-
identifier: { type: "removed" }
|
|
334
|
-
},
|
|
335
|
-
CodeBlock: {
|
|
336
|
-
namedImport: { type: "removed" },
|
|
337
|
-
identifier: { type: "removed" }
|
|
338
|
-
},
|
|
339
|
-
ConicGradient: {
|
|
340
|
-
namedImport: { type: "removed" },
|
|
341
|
-
identifier: { type: "removed" }
|
|
342
|
-
},
|
|
343
|
-
Drawer: {
|
|
344
|
-
namedImport: { type: "removed" },
|
|
345
|
-
identifier: { type: "removed" }
|
|
346
|
-
},
|
|
347
|
-
Emerald: {
|
|
348
|
-
namedImport: { type: "removed" },
|
|
349
|
-
identifier: { type: "removed" }
|
|
350
|
-
},
|
|
351
|
-
GreenFall: {
|
|
352
|
-
namedImport: { type: "removed" },
|
|
353
|
-
identifier: { type: "removed" }
|
|
354
|
-
},
|
|
355
|
-
LightSwitch: {
|
|
356
|
-
namedImport: { type: "removed" },
|
|
357
|
-
identifier: { type: "removed" }
|
|
358
|
-
},
|
|
359
|
-
ListBox: {
|
|
360
|
-
namedImport: { type: "removed" },
|
|
361
|
-
identifier: { type: "removed" }
|
|
362
|
-
},
|
|
363
|
-
ListBoxItem: {
|
|
364
|
-
namedImport: { type: "removed" },
|
|
365
|
-
identifier: { type: "removed" }
|
|
366
|
-
},
|
|
367
|
-
Modal: {
|
|
368
|
-
namedImport: { type: "removed" },
|
|
369
|
-
identifier: { type: "removed" }
|
|
370
|
-
},
|
|
371
|
-
Noir: {
|
|
372
|
-
namedImport: { type: "removed" },
|
|
373
|
-
identifier: { type: "removed" }
|
|
374
|
-
},
|
|
375
|
-
NoirLight: {
|
|
376
|
-
namedImport: { type: "removed" },
|
|
377
|
-
identifier: { type: "removed" }
|
|
378
|
-
},
|
|
379
|
-
RecursiveTreeView: {
|
|
380
|
-
namedImport: { type: "removed" },
|
|
381
|
-
identifier: { type: "removed" }
|
|
382
|
-
},
|
|
383
|
-
RecursiveTreeViewItem: {
|
|
384
|
-
namedImport: { type: "removed" },
|
|
385
|
-
identifier: { type: "removed" }
|
|
386
|
-
},
|
|
387
|
-
Rustic: {
|
|
388
|
-
namedImport: { type: "removed" },
|
|
389
|
-
identifier: { type: "removed" }
|
|
390
|
-
},
|
|
391
|
-
Step: {
|
|
392
|
-
namedImport: { type: "removed" },
|
|
393
|
-
identifier: { type: "removed" }
|
|
394
|
-
},
|
|
395
|
-
Stepper: {
|
|
396
|
-
namedImport: { type: "removed" },
|
|
397
|
-
identifier: { type: "removed" }
|
|
398
|
-
},
|
|
399
|
-
Summer84: {
|
|
400
|
-
namedImport: { type: "removed" },
|
|
401
|
-
identifier: { type: "removed" }
|
|
402
|
-
},
|
|
403
|
-
Table: {
|
|
404
|
-
namedImport: { type: "removed" },
|
|
405
|
-
identifier: { type: "removed" }
|
|
406
|
-
},
|
|
407
|
-
TableOfContents: {
|
|
408
|
-
namedImport: { type: "removed" },
|
|
409
|
-
identifier: { type: "removed" }
|
|
410
|
-
},
|
|
411
|
-
TreeView: {
|
|
412
|
-
namedImport: { type: "removed" },
|
|
413
|
-
identifier: { type: "removed" }
|
|
414
|
-
},
|
|
415
|
-
TreeViewItem: {
|
|
416
|
-
namedImport: { type: "removed" },
|
|
417
|
-
identifier: { type: "removed" }
|
|
418
|
-
},
|
|
419
|
-
XPro: {
|
|
420
|
-
namedImport: { type: "removed" },
|
|
421
|
-
identifier: { type: "removed" }
|
|
422
|
-
},
|
|
423
|
-
autoModeWatcher: {
|
|
424
|
-
namedImport: { type: "removed" },
|
|
425
|
-
identifier: { type: "removed" }
|
|
426
|
-
},
|
|
427
|
-
clipboard: {
|
|
428
|
-
namedImport: { type: "removed" },
|
|
429
|
-
identifier: { type: "removed" }
|
|
430
|
-
},
|
|
431
|
-
filter: {
|
|
432
|
-
namedImport: { type: "removed" },
|
|
433
|
-
identifier: { type: "removed" }
|
|
434
|
-
},
|
|
435
|
-
focusTrap: {
|
|
436
|
-
namedImport: { type: "removed" },
|
|
437
|
-
identifier: { type: "removed" }
|
|
438
|
-
},
|
|
439
|
-
getDrawerStore: {
|
|
440
|
-
namedImport: { type: "removed" },
|
|
441
|
-
identifier: { type: "removed" }
|
|
442
|
-
},
|
|
443
|
-
getModalStore: {
|
|
444
|
-
namedImport: { type: "removed" },
|
|
445
|
-
identifier: { type: "removed" }
|
|
446
|
-
},
|
|
447
|
-
getModeAutoPrefers: {
|
|
448
|
-
namedImport: { type: "removed" },
|
|
449
|
-
identifier: { type: "removed" }
|
|
450
|
-
},
|
|
451
|
-
getModeOsPrefers: {
|
|
452
|
-
namedImport: { type: "removed" },
|
|
453
|
-
identifier: { type: "removed" }
|
|
454
|
-
},
|
|
455
|
-
getModeUserPrefers: {
|
|
456
|
-
namedImport: { type: "removed" },
|
|
457
|
-
identifier: { type: "removed" }
|
|
458
|
-
},
|
|
459
|
-
getToastStore: {
|
|
460
|
-
namedImport: { type: "removed" },
|
|
461
|
-
identifier: { type: "removed" }
|
|
462
|
-
},
|
|
463
|
-
initializeStores: {
|
|
464
|
-
namedImport: { type: "removed" },
|
|
465
|
-
identifier: { type: "removed" }
|
|
466
|
-
},
|
|
467
|
-
localStorageStore: {
|
|
468
|
-
namedImport: { type: "removed" },
|
|
469
|
-
identifier: { type: "removed" }
|
|
470
|
-
},
|
|
471
|
-
modeCurrent: {
|
|
472
|
-
namedImport: { type: "removed" },
|
|
473
|
-
identifier: { type: "removed" }
|
|
474
|
-
},
|
|
475
|
-
modeOsPrefers: {
|
|
476
|
-
namedImport: { type: "removed" },
|
|
477
|
-
identifier: { type: "removed" }
|
|
478
|
-
},
|
|
479
|
-
modeUserPrefers: {
|
|
480
|
-
namedImport: { type: "removed" },
|
|
481
|
-
identifier: { type: "removed" }
|
|
482
|
-
},
|
|
483
|
-
popup: {
|
|
484
|
-
namedImport: { type: "removed" },
|
|
485
|
-
identifier: { type: "removed" }
|
|
486
|
-
},
|
|
487
|
-
prefersReducedMotionStore: {
|
|
488
|
-
namedImport: { type: "removed" },
|
|
489
|
-
identifier: { type: "removed" }
|
|
490
|
-
},
|
|
491
|
-
setInitialClassState: {
|
|
492
|
-
namedImport: { type: "removed" },
|
|
493
|
-
identifier: { type: "removed" }
|
|
494
|
-
},
|
|
495
|
-
setModeCurrent: {
|
|
496
|
-
namedImport: { type: "removed" },
|
|
497
|
-
identifier: { type: "removed" }
|
|
498
|
-
},
|
|
499
|
-
setModeUserPrefers: {
|
|
500
|
-
namedImport: { type: "removed" },
|
|
501
|
-
identifier: { type: "removed" }
|
|
502
|
-
},
|
|
503
|
-
storeHighlightJs: {
|
|
504
|
-
namedImport: { type: "removed" },
|
|
505
|
-
identifier: { type: "removed" }
|
|
506
|
-
},
|
|
507
|
-
storePopup: {
|
|
508
|
-
namedImport: { type: "removed" },
|
|
509
|
-
identifier: { type: "removed" }
|
|
510
|
-
},
|
|
511
|
-
tableMapperValues: {
|
|
512
|
-
namedImport: { type: "removed" },
|
|
513
|
-
identifier: { type: "removed" }
|
|
514
|
-
},
|
|
515
|
-
tableSourceMapper: {
|
|
516
|
-
namedImport: { type: "removed" },
|
|
517
|
-
identifier: { type: "removed" }
|
|
518
|
-
},
|
|
519
|
-
tableSourceValues: {
|
|
520
|
-
namedImport: { type: "removed" },
|
|
521
|
-
identifier: { type: "removed" }
|
|
522
|
-
},
|
|
523
|
-
tocCrawler: {
|
|
524
|
-
namedImport: { type: "removed" },
|
|
525
|
-
identifier: { type: "removed" }
|
|
526
|
-
},
|
|
527
|
-
tocStore: {
|
|
528
|
-
namedImport: { type: "removed" },
|
|
529
|
-
identifier: { type: "removed" }
|
|
530
|
-
},
|
|
531
|
-
AppRail: {
|
|
532
|
-
namedImport: {
|
|
533
|
-
type: "renamed",
|
|
534
|
-
value: "Navigation"
|
|
535
|
-
},
|
|
536
|
-
identifier: {
|
|
537
|
-
type: "renamed",
|
|
538
|
-
value: "Navigation"
|
|
539
|
-
}
|
|
540
|
-
},
|
|
541
|
-
AppRailTile: {
|
|
542
|
-
namedImport: {
|
|
543
|
-
type: "renamed",
|
|
544
|
-
value: "Navigation"
|
|
545
|
-
},
|
|
546
|
-
identifier: {
|
|
547
|
-
type: "renamed",
|
|
548
|
-
value: "Navigation.Tile"
|
|
549
|
-
}
|
|
550
|
-
},
|
|
551
|
-
FileButton: {
|
|
552
|
-
namedImport: {
|
|
553
|
-
type: "renamed",
|
|
554
|
-
value: "FileUpload"
|
|
555
|
-
},
|
|
556
|
-
identifier: {
|
|
557
|
-
type: "renamed",
|
|
558
|
-
value: "FileUpload"
|
|
559
|
-
}
|
|
560
|
-
},
|
|
561
|
-
FileDropzone: {
|
|
562
|
-
namedImport: {
|
|
563
|
-
type: "renamed",
|
|
564
|
-
value: "FileUpload"
|
|
565
|
-
},
|
|
566
|
-
identifier: {
|
|
567
|
-
type: "renamed",
|
|
568
|
-
value: "FileUpload"
|
|
569
|
-
}
|
|
570
|
-
},
|
|
571
|
-
InputChip: {
|
|
572
|
-
namedImport: {
|
|
573
|
-
type: "renamed",
|
|
574
|
-
value: "TagsInput"
|
|
575
|
-
},
|
|
576
|
-
identifier: {
|
|
577
|
-
type: "renamed",
|
|
578
|
-
value: "TagsInput"
|
|
579
|
-
}
|
|
580
|
-
},
|
|
581
|
-
Paginator: {
|
|
582
|
-
namedImport: {
|
|
583
|
-
type: "renamed",
|
|
584
|
-
value: "Pagination"
|
|
585
|
-
},
|
|
586
|
-
identifier: {
|
|
587
|
-
type: "renamed",
|
|
588
|
-
value: "Pagination"
|
|
589
|
-
}
|
|
590
|
-
},
|
|
591
|
-
ProgressBar: {
|
|
592
|
-
namedImport: {
|
|
593
|
-
type: "renamed",
|
|
594
|
-
value: "Progress"
|
|
595
|
-
},
|
|
596
|
-
identifier: {
|
|
597
|
-
type: "renamed",
|
|
598
|
-
value: "Progress"
|
|
599
|
-
}
|
|
600
|
-
},
|
|
601
|
-
ProgressRadial: {
|
|
602
|
-
namedImport: {
|
|
603
|
-
type: "renamed",
|
|
604
|
-
value: "ProgressRing"
|
|
605
|
-
},
|
|
606
|
-
identifier: {
|
|
607
|
-
type: "renamed",
|
|
608
|
-
value: "ProgressRing"
|
|
609
|
-
}
|
|
610
|
-
},
|
|
611
|
-
RadioGroup: {
|
|
612
|
-
namedImport: {
|
|
613
|
-
type: "renamed",
|
|
614
|
-
value: "Segment"
|
|
615
|
-
},
|
|
616
|
-
identifier: {
|
|
617
|
-
type: "renamed",
|
|
618
|
-
value: "Segment"
|
|
619
|
-
}
|
|
620
|
-
},
|
|
621
|
-
RadioItem: {
|
|
622
|
-
namedImport: {
|
|
623
|
-
type: "renamed",
|
|
624
|
-
value: "Segment"
|
|
625
|
-
},
|
|
626
|
-
identifier: {
|
|
627
|
-
type: "renamed",
|
|
628
|
-
value: "Segment.Item"
|
|
629
|
-
}
|
|
630
|
-
},
|
|
631
|
-
RangeSlider: {
|
|
632
|
-
namedImport: {
|
|
633
|
-
type: "renamed",
|
|
634
|
-
value: "Slider"
|
|
635
|
-
},
|
|
636
|
-
identifier: {
|
|
637
|
-
type: "renamed",
|
|
638
|
-
value: "Slider"
|
|
639
|
-
}
|
|
640
|
-
},
|
|
641
|
-
Ratings: {
|
|
642
|
-
namedImport: {
|
|
643
|
-
type: "renamed",
|
|
644
|
-
value: "Rating"
|
|
645
|
-
},
|
|
646
|
-
identifier: {
|
|
647
|
-
type: "renamed",
|
|
648
|
-
value: "Rating"
|
|
649
|
-
}
|
|
650
|
-
},
|
|
651
|
-
SlideToggle: {
|
|
652
|
-
namedImport: {
|
|
653
|
-
type: "renamed",
|
|
654
|
-
value: "Switch"
|
|
655
|
-
},
|
|
656
|
-
identifier: {
|
|
657
|
-
type: "renamed",
|
|
658
|
-
value: "Switch"
|
|
659
|
-
}
|
|
660
|
-
},
|
|
661
|
-
TabAnchor: {
|
|
662
|
-
namedImport: {
|
|
663
|
-
type: "renamed",
|
|
664
|
-
value: "Tabs"
|
|
665
|
-
},
|
|
666
|
-
identifier: {
|
|
667
|
-
type: "renamed",
|
|
668
|
-
value: "Tabs.Control"
|
|
669
|
-
}
|
|
670
|
-
},
|
|
671
|
-
TabGroup: {
|
|
672
|
-
namedImport: {
|
|
673
|
-
type: "renamed",
|
|
674
|
-
value: "Tabs"
|
|
675
|
-
},
|
|
676
|
-
identifier: {
|
|
677
|
-
type: "renamed",
|
|
678
|
-
value: "Tabs"
|
|
679
|
-
}
|
|
680
|
-
},
|
|
681
|
-
Toast: {
|
|
682
|
-
namedImport: {
|
|
683
|
-
type: "renamed",
|
|
684
|
-
value: "ToastProvider"
|
|
685
|
-
},
|
|
686
|
-
identifier: {
|
|
687
|
-
type: "renamed",
|
|
688
|
-
value: "ToastProvider"
|
|
689
|
-
}
|
|
690
|
-
}
|
|
691
|
-
};
|
|
692
|
-
|
|
693
|
-
function transformModule(code) {
|
|
694
|
-
const file = parseSourceFile(code);
|
|
695
|
-
const skeletonImports = [];
|
|
696
|
-
file.forEachDescendant((node) => {
|
|
697
|
-
if (Node.isImportDeclaration(node)) {
|
|
698
|
-
const moduleSpecifier = node.getModuleSpecifier();
|
|
699
|
-
if (moduleSpecifier.getLiteralText() === "@skeletonlabs/skeleton") {
|
|
700
|
-
node.setModuleSpecifier("@skeletonlabs/skeleton-svelte");
|
|
701
|
-
}
|
|
702
|
-
}
|
|
703
|
-
if (Node.isImportSpecifier(node) && node.getImportDeclaration().getModuleSpecifier().getLiteralText() === "@skeletonlabs/skeleton-svelte") {
|
|
704
|
-
const name = node.getName();
|
|
705
|
-
if (Object.hasOwn(EXPORT_MAPPINGS, name)) {
|
|
706
|
-
const exportMapping = EXPORT_MAPPINGS[name];
|
|
707
|
-
switch (exportMapping.namedImport.type) {
|
|
708
|
-
case "renamed": {
|
|
709
|
-
if (exportMapping.namedImport.value.match(/^[A-Za-z]+\.[A-Za-z]+$/)) {
|
|
710
|
-
break;
|
|
711
|
-
}
|
|
712
|
-
node.remove();
|
|
713
|
-
addNamedImport(file, "@skeletonlabs/skeleton-svelte", exportMapping.namedImport.value);
|
|
714
|
-
break;
|
|
715
|
-
}
|
|
716
|
-
case "removed": {
|
|
717
|
-
const parent = node.getImportDeclaration();
|
|
718
|
-
if (parent.getNamedImports().length === 1 && !parent.getDefaultImport() && !parent.getNamespaceImport()) {
|
|
719
|
-
parent.remove();
|
|
720
|
-
} else {
|
|
721
|
-
node.remove();
|
|
722
|
-
}
|
|
723
|
-
break;
|
|
724
|
-
}
|
|
725
|
-
}
|
|
726
|
-
skeletonImports.push(name);
|
|
727
|
-
}
|
|
728
|
-
}
|
|
729
|
-
});
|
|
730
|
-
file.forEachDescendant((node) => {
|
|
731
|
-
if (!node.wasForgotten() && Node.isIdentifier(node) && !Node.isImportSpecifier(node.getParent())) {
|
|
732
|
-
const name = node.getText();
|
|
733
|
-
if (Object.hasOwn(EXPORT_MAPPINGS, name) && skeletonImports.includes(name)) {
|
|
734
|
-
const exportMapping = EXPORT_MAPPINGS[name];
|
|
735
|
-
if (exportMapping.identifier.type === "renamed") {
|
|
736
|
-
node.replaceWithText(exportMapping.identifier.value);
|
|
737
|
-
}
|
|
738
|
-
}
|
|
739
|
-
}
|
|
740
|
-
if (!node.wasForgotten() && Node.isStringLiteral(node) && !Node.isImportDeclaration(node.getParent())) {
|
|
741
|
-
node.replaceWithText(transformClasses(node.getText()).code);
|
|
742
|
-
}
|
|
743
|
-
});
|
|
744
|
-
return {
|
|
745
|
-
code: file.getFullText(),
|
|
746
|
-
meta: {
|
|
747
|
-
skeletonImports
|
|
748
|
-
}
|
|
749
|
-
};
|
|
750
|
-
}
|
|
751
|
-
|
|
752
|
-
function transformStyleSheet(code) {
|
|
753
|
-
const parsed = parse(code);
|
|
754
|
-
parsed.walkAtRules("apply", (atRule) => {
|
|
755
|
-
atRule.params = transformClasses(atRule.params).code;
|
|
756
|
-
});
|
|
757
|
-
return {
|
|
758
|
-
code: parsed.toString()
|
|
759
|
-
};
|
|
760
|
-
}
|
|
761
|
-
|
|
762
|
-
function renameComponent(s, node, name) {
|
|
763
|
-
const adjustedStart = node.start + 1;
|
|
764
|
-
s.update(adjustedStart, adjustedStart + node.name.length, name);
|
|
765
|
-
const componentString = s.original.slice(node.start, node.end);
|
|
766
|
-
const indexOfNonSelfClosingTag = componentString.lastIndexOf("</");
|
|
767
|
-
if (indexOfNonSelfClosingTag === -1 || node.start + indexOfNonSelfClosingTag > node.end) {
|
|
768
|
-
return;
|
|
769
|
-
}
|
|
770
|
-
s.update(node.start + indexOfNonSelfClosingTag + 2, node.start + indexOfNonSelfClosingTag + 2 + node.name.length, name);
|
|
771
|
-
}
|
|
772
|
-
function transformScript(s, script) {
|
|
773
|
-
if (!script || !("start" in script.content && typeof script.content.start === "number" && "end" in script.content && typeof script.content.end === "number")) {
|
|
774
|
-
return {
|
|
775
|
-
meta: {
|
|
776
|
-
skeletonImports: []
|
|
777
|
-
}
|
|
778
|
-
};
|
|
779
|
-
}
|
|
780
|
-
const content = s.original.slice(script.content.start, script.content.end);
|
|
781
|
-
const transformed = transformModule(content);
|
|
782
|
-
s.overwrite(script.content.start, script.content.end, transformed.code);
|
|
783
|
-
return {
|
|
784
|
-
meta: transformed.meta
|
|
785
|
-
};
|
|
786
|
-
}
|
|
787
|
-
function transformCss(s, css) {
|
|
788
|
-
if (!css) {
|
|
789
|
-
return;
|
|
790
|
-
}
|
|
791
|
-
const transformed = transformStyleSheet(s.original.slice(css.content.start, css.content.end));
|
|
792
|
-
s.overwrite(css.content.start, css.content.end, transformed.code);
|
|
793
|
-
}
|
|
794
|
-
function hasRange(node) {
|
|
795
|
-
return "start" in node && "end" in node && typeof node.start === "number" && typeof node.end === "number";
|
|
796
|
-
}
|
|
797
|
-
function transformFragment(s, fragment, skeletonImports) {
|
|
798
|
-
walk(
|
|
799
|
-
fragment,
|
|
800
|
-
{},
|
|
801
|
-
{
|
|
802
|
-
Literal(node, ctx) {
|
|
803
|
-
const parent = ctx.path.at(-1);
|
|
804
|
-
if (typeof node.raw === "string" && node.raw !== "" && !(parent && parent.type === "ImportDeclaration") && hasRange(node)) {
|
|
805
|
-
s.update(node.start, node.end, transformClasses(node.raw).code);
|
|
806
|
-
}
|
|
807
|
-
ctx.next();
|
|
808
|
-
},
|
|
809
|
-
Text(node, ctx) {
|
|
810
|
-
if (node.data !== "" && hasRange(node)) {
|
|
811
|
-
s.update(node.start, node.end, transformClasses(node.data).code);
|
|
812
|
-
}
|
|
813
|
-
ctx.next();
|
|
814
|
-
},
|
|
815
|
-
ClassDirective(node, ctx) {
|
|
816
|
-
if (!(node.expression.type === "Identifier" && !("loc" in node.expression) && node.name === node.expression.name) && hasRange(node)) {
|
|
817
|
-
const adjustedStart = node.start + "class:".length;
|
|
818
|
-
s.update(adjustedStart, adjustedStart + node.name.length, transformClasses(node.name).code);
|
|
819
|
-
}
|
|
820
|
-
ctx.next();
|
|
821
|
-
},
|
|
822
|
-
Component(node, ctx) {
|
|
823
|
-
if (Object.hasOwn(EXPORT_MAPPINGS, node.name) && skeletonImports.includes(node.name)) {
|
|
824
|
-
const exportMapping = EXPORT_MAPPINGS[node.name];
|
|
825
|
-
if (exportMapping.identifier.type === "renamed" && hasRange(node)) {
|
|
826
|
-
renameComponent(s, node, exportMapping.identifier.value);
|
|
827
|
-
}
|
|
828
|
-
}
|
|
829
|
-
ctx.next();
|
|
830
|
-
}
|
|
831
|
-
}
|
|
832
|
-
);
|
|
833
|
-
return {
|
|
834
|
-
code: s.toString()
|
|
835
|
-
};
|
|
836
|
-
}
|
|
837
|
-
function transformSvelte(code) {
|
|
838
|
-
const s = new MagicString(code);
|
|
839
|
-
const root = parse$1(code, {
|
|
840
|
-
modern: true
|
|
841
|
-
});
|
|
842
|
-
const skeletonImports = [
|
|
843
|
-
...transformScript(s, root.module).meta.skeletonImports,
|
|
844
|
-
...transformScript(s, root.instance).meta.skeletonImports
|
|
845
|
-
];
|
|
846
|
-
transformFragment(s, root.fragment, skeletonImports);
|
|
847
|
-
transformCss(s, root.css);
|
|
848
|
-
return {
|
|
849
|
-
code: s.toString()
|
|
850
|
-
};
|
|
851
|
-
}
|
|
852
|
-
|
|
853
|
-
const exec = promisify(child_process.exec);
|
|
854
|
-
async function installDependencies(cwd = process.cwd()) {
|
|
855
|
-
const pm = await detect({
|
|
856
|
-
cwd
|
|
857
|
-
});
|
|
858
|
-
const resolvedCommand = resolveCommand(pm?.agent ?? "npm", "install", []);
|
|
859
|
-
if (!resolvedCommand) {
|
|
860
|
-
throw new Error("Could not resolve package manager command.");
|
|
861
|
-
}
|
|
862
|
-
return exec(`${resolvedCommand.command} ${resolvedCommand.args.join(" ")}`, {
|
|
863
|
-
cwd
|
|
864
|
-
});
|
|
865
|
-
}
|
|
866
|
-
|
|
867
|
-
function getTailwindImport(root) {
|
|
868
|
-
let tailwindImport;
|
|
869
|
-
root.walkAtRules("import", (atRule2) => {
|
|
870
|
-
if (atRule2.params.includes("tailwindcss")) {
|
|
871
|
-
tailwindImport = atRule2;
|
|
872
|
-
}
|
|
873
|
-
});
|
|
874
|
-
return tailwindImport;
|
|
875
|
-
}
|
|
876
|
-
function transformAppCss(code, theme, addAtSource) {
|
|
877
|
-
code = transformStyleSheet(code).code;
|
|
878
|
-
const root = parse(code);
|
|
879
|
-
const nodes = [];
|
|
880
|
-
nodes.push(
|
|
881
|
-
atRule({
|
|
882
|
-
name: "import",
|
|
883
|
-
params: '"@skeletonlabs/skeleton"'
|
|
884
|
-
})
|
|
885
|
-
);
|
|
886
|
-
nodes.push(
|
|
887
|
-
atRule({
|
|
888
|
-
name: "import",
|
|
889
|
-
params: '"@skeletonlabs/skeleton/optional/presets"'
|
|
890
|
-
})
|
|
891
|
-
);
|
|
892
|
-
switch (theme.type) {
|
|
893
|
-
case "preset":
|
|
894
|
-
nodes.push(
|
|
895
|
-
atRule({
|
|
896
|
-
name: "import",
|
|
897
|
-
params: `"@skeletonlabs/skeleton/themes/${theme.value}"`
|
|
898
|
-
})
|
|
899
|
-
);
|
|
900
|
-
break;
|
|
901
|
-
case "custom":
|
|
902
|
-
nodes.push(comment({ text: `Add your theme import for your theme: "${theme.value}" here` }));
|
|
903
|
-
break;
|
|
904
|
-
}
|
|
905
|
-
if (addAtSource) {
|
|
906
|
-
nodes.push(
|
|
907
|
-
atRule({
|
|
908
|
-
name: "source",
|
|
909
|
-
params: '"../node_modules/@skeletonlabs/skeleton-svelte/dist"'
|
|
910
|
-
})
|
|
911
|
-
);
|
|
912
|
-
}
|
|
913
|
-
const tailwindImport = getTailwindImport(root);
|
|
914
|
-
if (tailwindImport) {
|
|
915
|
-
root.insertAfter(tailwindImport, nodes);
|
|
916
|
-
} else {
|
|
917
|
-
root.prepend(nodes);
|
|
918
|
-
}
|
|
919
|
-
return {
|
|
920
|
-
code: root.toString()
|
|
921
|
-
};
|
|
922
|
-
}
|
|
923
|
-
|
|
924
|
-
const THEME_MAPPINGS = {
|
|
925
|
-
skeleton: { type: "preset", value: "legacy" },
|
|
926
|
-
"gold-nouveau": { type: "preset", value: "nouveau" },
|
|
927
|
-
wintry: { type: "preset", value: "wintry" },
|
|
928
|
-
modern: { type: "preset", value: "modern" },
|
|
929
|
-
rocket: { type: "preset", value: "rocket" },
|
|
930
|
-
seafoam: { type: "preset", value: "seafoam" },
|
|
931
|
-
vintage: { type: "preset", value: "vintage" },
|
|
932
|
-
sahara: { type: "preset", value: "sahara" },
|
|
933
|
-
hamlindigo: { type: "preset", value: "hamlindigo" },
|
|
934
|
-
crimson: { type: "preset", value: "crimson" }
|
|
935
|
-
};
|
|
936
|
-
|
|
937
|
-
function transformAppHtml(code) {
|
|
938
|
-
const parsed = parse$2(code);
|
|
939
|
-
const html = parsed.querySelector("html");
|
|
940
|
-
const body = parsed.querySelector("body");
|
|
941
|
-
if (!(html && body)) {
|
|
942
|
-
return {
|
|
943
|
-
code,
|
|
944
|
-
meta: {
|
|
945
|
-
theme: void 0
|
|
946
|
-
}
|
|
947
|
-
};
|
|
948
|
-
}
|
|
949
|
-
const theme = body.getAttribute("data-theme");
|
|
950
|
-
if (!theme) {
|
|
951
|
-
return {
|
|
952
|
-
code,
|
|
953
|
-
meta: {
|
|
954
|
-
theme: void 0
|
|
955
|
-
}
|
|
956
|
-
};
|
|
957
|
-
}
|
|
958
|
-
let type;
|
|
959
|
-
body.removeAttribute("data-theme");
|
|
960
|
-
if (Object.hasOwn(THEME_MAPPINGS, theme)) {
|
|
961
|
-
html.setAttribute("data-theme", THEME_MAPPINGS[theme].value);
|
|
962
|
-
type = "preset";
|
|
963
|
-
} else {
|
|
964
|
-
html.setAttribute("data-theme", theme);
|
|
965
|
-
type = "custom";
|
|
966
|
-
}
|
|
967
|
-
return {
|
|
968
|
-
code: parsed.toString(),
|
|
969
|
-
meta: {
|
|
970
|
-
theme: {
|
|
971
|
-
value: theme,
|
|
972
|
-
type
|
|
973
|
-
}
|
|
974
|
-
}
|
|
975
|
-
};
|
|
976
|
-
}
|
|
977
|
-
|
|
978
|
-
const FALLBACK_THEME = {
|
|
979
|
-
type: "preset",
|
|
980
|
-
value: "cerberus"
|
|
981
|
-
};
|
|
982
|
-
|
|
983
|
-
async function skeleton3(options) {
|
|
984
|
-
const cwd = options.cwd ?? process.cwd();
|
|
985
|
-
const migrations = [];
|
|
986
|
-
const packageJson = {
|
|
987
|
-
name: "package.json",
|
|
988
|
-
paths: await glob("package.json", { cwd })
|
|
989
|
-
};
|
|
990
|
-
const appHtml = {
|
|
991
|
-
name: "src/app.html",
|
|
992
|
-
paths: await glob("src/app.html", { cwd })
|
|
993
|
-
};
|
|
994
|
-
const appCss = {
|
|
995
|
-
name: "src/app.css",
|
|
996
|
-
paths: await glob("src/app.css", { cwd })
|
|
997
|
-
};
|
|
998
|
-
for (const file of [packageJson, appHtml, appCss]) {
|
|
999
|
-
if (file.paths.length === 0) {
|
|
1000
|
-
cli.error(`"${file.name}" not found in directory "${cwd}".`);
|
|
1001
|
-
}
|
|
1002
|
-
if (file.paths.length > 1) {
|
|
1003
|
-
cli.error(`Multiple "${file.name}" entries found in directory: "${cwd}", please ensure there is only one`);
|
|
1004
|
-
}
|
|
1005
|
-
}
|
|
1006
|
-
const availableSourceFolders = await glob("*", {
|
|
1007
|
-
cwd,
|
|
1008
|
-
onlyDirectories: true,
|
|
1009
|
-
ignore: ["node_modules"]
|
|
1010
|
-
});
|
|
1011
|
-
const sourceFolders = await multiselect({
|
|
1012
|
-
message: "What folders make use of Skeleton? (classes, imports, etc.)",
|
|
1013
|
-
options: availableSourceFolders.map((folder) => ({ label: folder, value: folder })),
|
|
1014
|
-
initialValues: availableSourceFolders
|
|
1015
|
-
});
|
|
1016
|
-
if (isCancel(sourceFolders)) {
|
|
1017
|
-
cli.error("Migration canceled, nothing written to disk");
|
|
1018
|
-
return;
|
|
1019
|
-
}
|
|
1020
|
-
let isUsingComponents = false;
|
|
1021
|
-
const packageSpinner = spinner();
|
|
1022
|
-
packageSpinner.start(`Migrating ${packageJson.name}...`);
|
|
1023
|
-
try {
|
|
1024
|
-
const packageJsonCode = await readFile(packageJson.paths[0], "utf-8");
|
|
1025
|
-
const skeletonVersion = await getLatestVersion("@skeletonlabs/skeleton", { version: ">=3.0.0-0 <4.0.0" });
|
|
1026
|
-
const skeletonSvelteVersion = await getLatestVersion("@skeletonlabs/skeleton-svelte", { version: ">=1.0.0-0 <2.0.0" });
|
|
1027
|
-
const transformedPackageJson = transformPackageJson(packageJsonCode, skeletonVersion, skeletonSvelteVersion);
|
|
1028
|
-
isUsingComponents = transformedPackageJson.meta.isUsingComponents;
|
|
1029
|
-
migrations.push({ path: packageJson.paths[0], content: transformedPackageJson.code });
|
|
1030
|
-
packageSpinner.stop(`Successfully migrated ${packageJson.name}!`);
|
|
1031
|
-
} catch (e) {
|
|
1032
|
-
packageSpinner.stop(`Failed to migrate ${packageJson.name}: ${e instanceof Error ? e.message : "Unknown error"}`, 1);
|
|
1033
|
-
cli.error("Migration canceled, nothing written to disk");
|
|
1034
|
-
}
|
|
1035
|
-
let theme;
|
|
1036
|
-
const appHtmlSpinner = spinner();
|
|
1037
|
-
appHtmlSpinner.start(`Migrating ${appHtml.name}...`);
|
|
1038
|
-
try {
|
|
1039
|
-
const appHtmlCode = await readFile(appHtml.paths[0], "utf-8");
|
|
1040
|
-
const transformedAppHtml = transformAppHtml(appHtmlCode);
|
|
1041
|
-
if (transformedAppHtml.meta.theme && Object.hasOwn(THEME_MAPPINGS, transformedAppHtml.meta.theme.value)) {
|
|
1042
|
-
theme = THEME_MAPPINGS[transformedAppHtml.meta.theme.value];
|
|
1043
|
-
} else if (transformedAppHtml.meta.theme) {
|
|
1044
|
-
theme = transformedAppHtml.meta.theme;
|
|
1045
|
-
} else {
|
|
1046
|
-
theme = FALLBACK_THEME;
|
|
1047
|
-
}
|
|
1048
|
-
migrations.push({ path: appHtml.paths[0], content: transformedAppHtml.code });
|
|
1049
|
-
appHtmlSpinner.stop(`Successfully migrated ${appHtml.name}!`);
|
|
1050
|
-
} catch (e) {
|
|
1051
|
-
appHtmlSpinner.stop(`Failed to migrate ${appHtml.name}: ${e instanceof Error ? e.message : "Unknown error"}`, 1);
|
|
1052
|
-
cli.error("Migration canceled, nothing written to disk");
|
|
1053
|
-
}
|
|
1054
|
-
const appCssSpinner = spinner();
|
|
1055
|
-
appCssSpinner.start(`Migrating ${appCss.name}...`);
|
|
1056
|
-
try {
|
|
1057
|
-
const appCssCode = await readFile(appCss.paths[0], "utf-8");
|
|
1058
|
-
const transformedAppCss = transformAppCss(appCssCode, theme ?? FALLBACK_THEME, isUsingComponents);
|
|
1059
|
-
migrations.push({ path: appCss.paths[0], content: transformedAppCss.code });
|
|
1060
|
-
appCssSpinner.stop(`Successfully migrated ${appCss.name}!`);
|
|
1061
|
-
} catch (e) {
|
|
1062
|
-
appCssSpinner.stop(`Failed to migrate ${appCss.name}: ${e instanceof Error ? e.message : "Unknown error"}`, 1);
|
|
1063
|
-
cli.error("Migration canceled, nothing written to disk");
|
|
1064
|
-
}
|
|
1065
|
-
if (sourceFolders.length > 0) {
|
|
1066
|
-
const sourceFiles = await glob(
|
|
1067
|
-
sourceFolders.map((folder) => `${folder}**/*.{svelte,js,mjs,ts,mts,css,pcss,postcss}`),
|
|
1068
|
-
{
|
|
1069
|
-
cwd,
|
|
1070
|
-
ignore: ["node_modules", "src/app.css"]
|
|
1071
|
-
}
|
|
1072
|
-
);
|
|
1073
|
-
const sourceFilesSpinner = spinner();
|
|
1074
|
-
sourceFilesSpinner.start(`Migrating source files...`);
|
|
1075
|
-
for (const sourceFile of sourceFiles) {
|
|
1076
|
-
sourceFilesSpinner.message(`Migrating ${sourceFile}...`);
|
|
1077
|
-
const extension = extname(sourceFile);
|
|
1078
|
-
try {
|
|
1079
|
-
const code = await readFile(sourceFile, "utf-8");
|
|
1080
|
-
switch (extension) {
|
|
1081
|
-
case ".svelte": {
|
|
1082
|
-
const transformedSvelte = transformSvelte(code);
|
|
1083
|
-
migrations.push({ path: sourceFile, content: transformedSvelte.code });
|
|
1084
|
-
break;
|
|
1085
|
-
}
|
|
1086
|
-
case ".js":
|
|
1087
|
-
case ".mjs":
|
|
1088
|
-
case ".ts":
|
|
1089
|
-
case ".mts": {
|
|
1090
|
-
const transformedModule = transformModule(code);
|
|
1091
|
-
migrations.push({ path: sourceFile, content: transformedModule.code });
|
|
1092
|
-
break;
|
|
1093
|
-
}
|
|
1094
|
-
case ".css":
|
|
1095
|
-
case ".pcss":
|
|
1096
|
-
case ".postcss": {
|
|
1097
|
-
const transformedStyleSheet = transformStyleSheet(code);
|
|
1098
|
-
migrations.push({ path: sourceFile, content: transformedStyleSheet.code });
|
|
1099
|
-
break;
|
|
1100
|
-
}
|
|
1101
|
-
}
|
|
1102
|
-
sourceFilesSpinner.message(`Successfully migrated ${sourceFile}!`);
|
|
1103
|
-
} catch (e) {
|
|
1104
|
-
sourceFilesSpinner.stop(`Failed to migrate ${sourceFile}: ${e instanceof Error ? e.message : "Unknown error"}`, 1);
|
|
1105
|
-
cli.error("Migration canceled, nothing written to disk");
|
|
1106
|
-
}
|
|
1107
|
-
}
|
|
1108
|
-
sourceFilesSpinner.stop("Successfully migrated all source files!");
|
|
1109
|
-
}
|
|
1110
|
-
const writeSpinner = spinner();
|
|
1111
|
-
writeSpinner.start("Applying all migrations...");
|
|
1112
|
-
try {
|
|
1113
|
-
await Promise.all(migrations.map(({ path, content }) => writeFile(path, content)));
|
|
1114
|
-
writeSpinner.stop("Successfully applied all migrations!");
|
|
1115
|
-
} catch (e) {
|
|
1116
|
-
writeSpinner.stop(`Failed to apply migrations: ${e instanceof Error ? e.message.replace("\n", " ") : "Unknown error"}`, 1);
|
|
1117
|
-
cli.error("Migration canceled");
|
|
1118
|
-
}
|
|
1119
|
-
const installDependenciesSpinner = spinner();
|
|
1120
|
-
installDependenciesSpinner.start("Updating dependencies...");
|
|
1121
|
-
try {
|
|
1122
|
-
await installDependencies(cwd);
|
|
1123
|
-
installDependenciesSpinner.stop("Successfully updated dependencies!");
|
|
1124
|
-
} catch (e) {
|
|
1125
|
-
installDependenciesSpinner.stop(`Failed to update dependencies: ${e instanceof Error ? e.message : "Unknown error"}`, 1);
|
|
1126
|
-
cli.error("Migration canceled");
|
|
1127
|
-
return;
|
|
1128
|
-
}
|
|
1129
|
-
log.info("Migration complete! Visit https://skeleton.dev for more information.");
|
|
1130
|
-
}
|
|
1131
|
-
|
|
1132
|
-
const MIGRATIONS = {
|
|
1133
|
-
"skeleton-3": skeleton3
|
|
1134
|
-
};
|
|
1135
|
-
const migrate = new Command("migrate").description("Run a migration").addArgument(new Argument("<migration>", "The migration to run").choices(Object.keys(MIGRATIONS))).addOption(new Option("--cwd <cwd>", "The directory to run the migration in")).action((migration, options) => MIGRATIONS[migration](options));
|
|
1136
|
-
|
|
1137
|
-
async function getOurPackageJson() {
|
|
1138
|
-
const packageJsonPath = join(dirname(fileURLToPath(import.meta.url)), "../package.json");
|
|
1139
|
-
const content = await readFile(packageJsonPath, "utf-8");
|
|
1140
|
-
return JSON.parse(content);
|
|
1141
|
-
}
|
|
1142
|
-
|
|
1143
|
-
const pkg = await getOurPackageJson();
|
|
1144
|
-
const cli = new Command().name(pkg.name).description(pkg.description).version(pkg.version).addCommand(migrate).copyInheritedSettings(migrate).configureOutput({
|
|
1145
|
-
writeOut: log.info,
|
|
1146
|
-
writeErr(str) {
|
|
1147
|
-
outro(red(str.replace("\n", " ")));
|
|
1148
|
-
process.exit(1);
|
|
1149
|
-
}
|
|
1150
|
-
}).hook("preAction", (_, ctx) => {
|
|
1151
|
-
const args = ctx.args.join(" ");
|
|
1152
|
-
log.message(dim(`Running "${`${ctx.name()}${args ? ` ${args}` : ""}`}"...`));
|
|
1153
|
-
});
|
|
1154
|
-
async function main() {
|
|
1155
|
-
intro(bgBlueBright(black(" Welcome to the Skeleton CLI \u{1F480} ")));
|
|
1156
|
-
if (process.argv.length === 2) {
|
|
1157
|
-
cli.error("error: no command provided");
|
|
1158
|
-
}
|
|
1159
|
-
await cli.parseAsync(process.argv);
|
|
1160
|
-
outro(bgGreenBright(black(" All Done! ")));
|
|
1161
|
-
}
|
|
1162
|
-
await main();
|
|
1163
|
-
|
|
1164
|
-
export { cli };
|