@ykdz/template 0.0.5 → 0.0.6

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.
@@ -1,766 +0,0 @@
1
- import { existsSync } from "node:fs";
2
- import { readFile } from "node:fs/promises";
3
- import path from "node:path";
4
- import { fileURLToPath } from "node:url";
5
- import { collectGeneratedManifestCatalogDependencies, renderGeneratedPnpmWorkspaceYaml, } from "../../src/dependency-catalog.js";
6
- import { browserTestToolLayer, checkedDockerfileFirstNodePnpmDevcontainer, nodePnpmToolLayer, } from "../../src/devcontainer.js";
7
- import { editorCustomizationForCapabilities } from "../../src/editor-customization.js";
8
- import { renderFixCommand, renderRootCheckCommand, } from "../../src/module-graph.js";
9
- import { PackageAdditionSupport } from "../../src/package-addition-support.js";
10
- import { packageTurboTasks } from "../../src/package-linking.js";
11
- import { renderNewProject } from "../../src/renderer.js";
12
- const generatedBy = {
13
- packageName: "@ykdz/template",
14
- version: "0.0.0",
15
- command: "template init --preset vue-app",
16
- };
17
- export const vueAppPresetMetadata = {
18
- name: "vue-app",
19
- title: "Vue app",
20
- description: "Vue app workspace with Vite, Tailwind, Pinia, and test tooling.",
21
- generation: "supported",
22
- supportedPackageManagers: ["pnpm"],
23
- supportedProjectKinds: ["multi-package"],
24
- packageAdditionSupport: PackageAdditionSupport.Supported,
25
- features: [
26
- "pnpm-catalog",
27
- "oxc-format-lint",
28
- "strict-typescript",
29
- "root-check",
30
- "fix-command",
31
- "devcontainer",
32
- "github-actions",
33
- "dependabot",
34
- ],
35
- };
36
- const dependencyMaintenancePolicy = {
37
- ecosystems: ["npm", "github-actions", "docker"],
38
- interval: "weekly",
39
- };
40
- const webPackageBoundary = {
41
- kind: "package-boundary",
42
- path: ".",
43
- };
44
- const rootBoundary = {
45
- kind: "workspace-orchestration",
46
- path: ".",
47
- };
48
- const workspacePackageBoundary = {
49
- kind: "package-boundary",
50
- path: "apps/*",
51
- };
52
- const webWorkspaceBoundary = {
53
- kind: "package-boundary",
54
- path: "apps/web",
55
- };
56
- function planVueAppPackageChecks() {
57
- return {
58
- components: [
59
- { kind: "oxc-format-check", owner: webPackageBoundary },
60
- { kind: "oxc-lint", owner: webPackageBoundary },
61
- { kind: "typescript-typecheck", owner: webPackageBoundary },
62
- { kind: "build", owner: webPackageBoundary },
63
- { kind: "unit-test", owner: webPackageBoundary },
64
- { kind: "e2e-test", owner: webPackageBoundary },
65
- ],
66
- environmentNeeds: [],
67
- };
68
- }
69
- function planVueAppRootChecks() {
70
- return {
71
- components: [
72
- { kind: "oxc-format-check", owner: rootBoundary },
73
- { kind: "oxc-lint", owner: rootBoundary },
74
- { kind: "typescript-typecheck", owner: rootBoundary },
75
- { kind: "turbo-package-typecheck", owner: workspacePackageBoundary },
76
- { kind: "turbo-package-build", owner: workspacePackageBoundary },
77
- { kind: "turbo-package-test", owner: workspacePackageBoundary },
78
- { kind: "turbo-package-e2e-test", owner: workspacePackageBoundary },
79
- { kind: "turbo-package-check", owner: workspacePackageBoundary },
80
- ],
81
- environmentNeeds: [
82
- {
83
- kind: "playwright-browser-assets",
84
- browser: "chromium",
85
- owner: webWorkspaceBoundary,
86
- },
87
- ],
88
- };
89
- }
90
- function planVueAppPackageFixes() {
91
- return {
92
- components: [
93
- { kind: "oxc-format-write", owner: webPackageBoundary },
94
- { kind: "oxc-lint-fix", owner: webPackageBoundary },
95
- ],
96
- };
97
- }
98
- function planVueAppRootFixes() {
99
- return {
100
- components: [
101
- { kind: "oxc-format-write", owner: rootBoundary },
102
- { kind: "oxc-lint-fix", owner: rootBoundary },
103
- { kind: "turbo-package-fix", owner: workspacePackageBoundary },
104
- ],
105
- };
106
- }
107
- function projectNameFromDir(targetDir) {
108
- return path.basename(path.resolve(targetDir));
109
- }
110
- function packageScopeFromOptions(options) {
111
- return options.scope ?? projectNameFromDir(options.targetDir);
112
- }
113
- function packageName(packageScope) {
114
- return `@${packageScope}/web`;
115
- }
116
- export function vueAppBlueprint(options = { targetDir: process.cwd() }) {
117
- const packageScope = packageScopeFromOptions(options);
118
- return {
119
- schemaVersion: 1,
120
- preset: "vue-app",
121
- packageManager: "pnpm",
122
- projectKind: "multi-package",
123
- features: [...vueAppPresetMetadata.features],
124
- packages: [{ name: packageName(packageScope), path: "apps/web" }],
125
- };
126
- }
127
- function projectVueAppRootPackageScripts() {
128
- return {
129
- check: renderRootCheckCommand(planVueAppRootChecks()),
130
- fix: renderFixCommand(planVueAppRootFixes()),
131
- "format:check": "oxfmt --check --config oxfmt.config.ts oxlint.config.ts oxfmt.config.ts",
132
- "format:write": "oxfmt --write --config oxfmt.config.ts oxlint.config.ts oxfmt.config.ts",
133
- lint: "oxlint --config oxlint.config.ts oxlint.config.ts oxfmt.config.ts --deny-warnings",
134
- "lint:fix": "oxlint --config oxlint.config.ts oxlint.config.ts oxfmt.config.ts --fix --deny-warnings",
135
- typecheck: "tsc -p tsconfig.config.json --noEmit",
136
- };
137
- }
138
- export function projectVueAppPackageScripts() {
139
- return {
140
- build: "vite build",
141
- check: renderRootCheckCommand(planVueAppPackageChecks()),
142
- dev: "vite",
143
- fix: renderFixCommand(planVueAppPackageFixes()),
144
- "format:check": "oxfmt --check --config ../../oxfmt.config.ts .",
145
- "format:write": "oxfmt --write --config ../../oxfmt.config.ts .",
146
- lint: "oxlint --config ../../oxlint.config.ts . --deny-warnings",
147
- "lint:fix": "oxlint --config ../../oxlint.config.ts . --fix --deny-warnings",
148
- preview: "vite preview",
149
- test: "vitest run",
150
- "test:e2e": "pnpm run build && playwright test",
151
- typecheck: "vue-tsc --build --noEmit",
152
- };
153
- }
154
- function rootPackageJson(context, packageScripts) {
155
- return {
156
- name: context.projectName.value,
157
- version: "0.0.0",
158
- private: true,
159
- type: "module",
160
- scripts: packageScripts,
161
- devDependencies: {
162
- oxfmt: "catalog:",
163
- oxlint: "catalog:",
164
- turbo: "catalog:",
165
- typescript: "catalog:",
166
- },
167
- engines: {
168
- node: context.toolchain.nodeLtsMajor.value,
169
- },
170
- packageManager: context.toolchain.packageManagerPin.value,
171
- };
172
- }
173
- function webPackageName(context) {
174
- const webPackage = context.blueprint.packages?.find((pkg) => pkg.path === "apps/web");
175
- return webPackage?.name ?? packageName(context.projectName.value);
176
- }
177
- function webPackageJson(context) {
178
- return {
179
- name: webPackageName(context),
180
- version: "0.0.0",
181
- private: true,
182
- type: "module",
183
- imports: {
184
- "#/*": {
185
- default: "./src/*.ts",
186
- types: "./src/*.ts",
187
- },
188
- },
189
- scripts: projectVueAppPackageScripts(),
190
- dependencies: {
191
- "@vueuse/core": "catalog:",
192
- pinia: "catalog:",
193
- vue: "catalog:",
194
- },
195
- devDependencies: {
196
- "@playwright/test": "catalog:",
197
- "@tailwindcss/vite": "catalog:",
198
- "@types/node": "catalog:",
199
- "@types/web-bluetooth": "catalog:",
200
- "@vitejs/plugin-vue": "catalog:",
201
- "@vue/tsconfig": "catalog:",
202
- oxfmt: "catalog:",
203
- oxlint: "catalog:",
204
- tailwindcss: "catalog:",
205
- typescript: "catalog:",
206
- vite: "catalog:",
207
- vitest: "catalog:",
208
- "vue-tsc": "catalog:",
209
- },
210
- engines: {
211
- node: context.toolchain.nodeLtsMajor.value,
212
- },
213
- };
214
- }
215
- function generationRecord(context) {
216
- return {
217
- ...generatedBy,
218
- toolchain: {
219
- nodeLtsMajor: context.toolchain.nodeLtsMajor.value,
220
- packageManagerPin: context.toolchain.packageManagerPin.value,
221
- source: context.toolchain.source,
222
- },
223
- };
224
- }
225
- function operationsForVueApp(context, packageScripts, checkPlan) {
226
- const editorCustomization = editorCustomizationForCapabilities([
227
- "oxc-format-lint",
228
- "vue",
229
- "tailwind",
230
- "vitest",
231
- ]);
232
- const developmentContainer = checkedDockerfileFirstNodePnpmDevcontainer({
233
- name: context.projectName.value,
234
- layer: nodePnpmToolLayer({
235
- nodeVersion: context.toolchain.nodeLtsMajor.value,
236
- packageManagerPin: context.toolchain.packageManagerPin.value,
237
- }),
238
- additionalLayers: [browserTestToolLayer()],
239
- extensions: editorCustomization.extensions,
240
- settings: editorCustomization.settings,
241
- });
242
- const rootManifest = rootPackageJson(context, packageScripts);
243
- const webManifest = webPackageJson(context);
244
- const turboTasks = packageTurboTasks({ dependencyBuildsRequired: false });
245
- return [
246
- {
247
- kind: "writeJson",
248
- to: "package.json",
249
- value: rootManifest,
250
- },
251
- {
252
- kind: "writeText",
253
- to: "pnpm-workspace.yaml",
254
- text: renderGeneratedPnpmWorkspaceYaml({
255
- packages: ["apps/*"],
256
- dependencies: collectGeneratedManifestCatalogDependencies([
257
- rootManifest,
258
- webManifest,
259
- ]),
260
- allowBuilds: {
261
- esbuild: true,
262
- },
263
- }),
264
- },
265
- {
266
- kind: "writeJson",
267
- to: "turbo.json",
268
- value: {
269
- tasks: {
270
- build: turboTasks.build,
271
- check: turboTasks.check,
272
- typecheck: turboTasks.typecheck,
273
- test: turboTasks.test,
274
- "test:e2e": turboTasks["test:e2e"],
275
- dev: {
276
- cache: false,
277
- persistent: true,
278
- },
279
- fix: {
280
- cache: false,
281
- },
282
- },
283
- },
284
- },
285
- {
286
- kind: "writeJson",
287
- to: "tsconfig.json",
288
- value: {
289
- files: [],
290
- references: [
291
- { path: "./apps/web/tsconfig.app.json" },
292
- { path: "./apps/web/tsconfig.test.json" },
293
- { path: "./apps/web/tsconfig.node.json" },
294
- ],
295
- },
296
- },
297
- {
298
- kind: "writeJson",
299
- to: "tsconfig.config.json",
300
- value: {
301
- compilerOptions: {
302
- module: "NodeNext",
303
- moduleResolution: "NodeNext",
304
- noEmitOnError: true,
305
- skipLibCheck: false,
306
- strict: true,
307
- target: "ES2022",
308
- },
309
- include: ["oxlint.config.ts", "oxfmt.config.ts"],
310
- },
311
- },
312
- {
313
- kind: "writeJson",
314
- to: "apps/web/package.json",
315
- value: webManifest,
316
- },
317
- {
318
- kind: "writeJson",
319
- to: "apps/web/tsconfig.json",
320
- value: {
321
- files: [],
322
- references: [
323
- { path: "./tsconfig.app.json" },
324
- { path: "./tsconfig.test.json" },
325
- { path: "./tsconfig.node.json" },
326
- ],
327
- },
328
- },
329
- {
330
- kind: "writeJson",
331
- to: "apps/web/tsconfig.app.json",
332
- value: {
333
- extends: "@vue/tsconfig/tsconfig.dom.json",
334
- compilerOptions: {
335
- composite: true,
336
- module: "ESNext",
337
- moduleResolution: "Bundler",
338
- noEmitOnError: true,
339
- skipLibCheck: false,
340
- strict: true,
341
- target: "ES2022",
342
- tsBuildInfoFile: "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
343
- types: ["web-bluetooth"],
344
- },
345
- include: ["env.d.ts", "src/**/*.ts", "src/**/*.vue"],
346
- },
347
- },
348
- {
349
- kind: "writeJson",
350
- to: "apps/web/tsconfig.test.json",
351
- value: {
352
- extends: "./tsconfig.app.json",
353
- compilerOptions: {
354
- lib: ["ESNext", "DOM", "DOM.Iterable"],
355
- tsBuildInfoFile: "./node_modules/.tmp/tsconfig.test.tsbuildinfo",
356
- types: ["node", "vitest/globals", "web-bluetooth"],
357
- },
358
- include: ["env.d.ts", "src/**/*.ts", "src/**/*.vue", "test/**/*.ts"],
359
- },
360
- },
361
- {
362
- kind: "writeJson",
363
- to: "apps/web/tsconfig.node.json",
364
- value: {
365
- compilerOptions: {
366
- composite: true,
367
- module: "ESNext",
368
- moduleResolution: "Bundler",
369
- noEmitOnError: true,
370
- lib: ["ESNext", "DOM", "DOM.Iterable"],
371
- skipLibCheck: false,
372
- strict: true,
373
- target: "ES2022",
374
- tsBuildInfoFile: "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
375
- types: ["node"],
376
- },
377
- include: ["playwright.config.ts", "vite.config.ts", "vitest.config.ts"],
378
- },
379
- },
380
- {
381
- kind: "copyFile",
382
- sourceRoot: "sharedOxc",
383
- from: "vue/oxlint.config.ts",
384
- to: "oxlint.config.ts",
385
- },
386
- {
387
- kind: "copyFile",
388
- sourceRoot: "sharedOxc",
389
- from: "oxfmt.config.ts",
390
- to: "oxfmt.config.ts",
391
- },
392
- {
393
- kind: "writeText",
394
- to: ".gitignore",
395
- text: [
396
- "node_modules",
397
- "dist",
398
- "playwright-report",
399
- "test-results",
400
- ".env",
401
- ".template/",
402
- ".pnpm-store/",
403
- "",
404
- ].join("\n"),
405
- },
406
- { kind: "copyFile", from: "env.d.ts", to: "apps/web/env.d.ts" },
407
- { kind: "copyFile", from: "index.html", to: "apps/web/index.html" },
408
- {
409
- kind: "copyFile",
410
- from: "playwright.config.ts",
411
- to: "apps/web/playwright.config.ts",
412
- },
413
- { kind: "copyFile", from: "vite.config.ts", to: "apps/web/vite.config.ts" },
414
- {
415
- kind: "copyFile",
416
- from: "vitest.config.ts",
417
- to: "apps/web/vitest.config.ts",
418
- },
419
- { kind: "copyFile", from: "src/App.vue", to: "apps/web/src/App.vue" },
420
- { kind: "copyFile", from: "src/main.ts", to: "apps/web/src/main.ts" },
421
- { kind: "copyFile", from: "src/style.css", to: "apps/web/src/style.css" },
422
- {
423
- kind: "copyFile",
424
- from: "src/stores/counter.ts",
425
- to: "apps/web/src/stores/counter.ts",
426
- },
427
- {
428
- kind: "copyFile",
429
- from: "test/app.test.ts",
430
- to: "apps/web/test/app.test.ts",
431
- },
432
- {
433
- kind: "copyFile",
434
- from: "test/e2e/app.spec.ts",
435
- to: "apps/web/test/e2e/app.spec.ts",
436
- },
437
- {
438
- kind: "writeJson",
439
- to: ".template/blueprint.json",
440
- value: context.blueprint,
441
- },
442
- {
443
- kind: "writeJson",
444
- to: ".template/generated-by.json",
445
- value: generationRecord(context),
446
- },
447
- {
448
- kind: "writeJson",
449
- to: ".devcontainer/devcontainer.json",
450
- value: developmentContainer.devcontainer,
451
- },
452
- {
453
- ...developmentContainer.dockerfileOperation,
454
- },
455
- {
456
- kind: "writeJson",
457
- to: ".vscode/extensions.json",
458
- value: {
459
- recommendations: editorCustomization.extensions,
460
- },
461
- multilineArrays: ["recommendations"],
462
- },
463
- {
464
- kind: "writeJson",
465
- to: ".vscode/settings.json",
466
- value: editorCustomization.settings,
467
- },
468
- {
469
- kind: "copyFile",
470
- from: ".github/workflows/check.yml",
471
- to: ".github/workflows/check.yml",
472
- },
473
- {
474
- kind: "copyFile",
475
- from: ".github/dependabot.yml",
476
- to: ".github/dependabot.yml",
477
- },
478
- ];
479
- }
480
- function isNodeError(error) {
481
- return error instanceof Error && "code" in error;
482
- }
483
- function localPortsFromText(text) {
484
- return [
485
- ...text.matchAll(/port:\s*(\d+)/g),
486
- ...text.matchAll(/--port\s+(\d+)/g),
487
- ...text.matchAll(/https?:\/\/(?:localhost|127\.0\.0\.1):(\d+)/g),
488
- ].map((match) => Number(match[1]));
489
- }
490
- async function usedPlaywrightPorts(root, blueprint) {
491
- const ports = new Set();
492
- for (const projectPackage of blueprint.packages ?? []) {
493
- try {
494
- const configText = await readFile(path.join(root, projectPackage.path, "playwright.config.ts"), "utf8");
495
- for (const port of localPortsFromText(configText)) {
496
- ports.add(port);
497
- }
498
- }
499
- catch (error) {
500
- if (!isNodeError(error) || error.code !== "ENOENT") {
501
- throw error;
502
- }
503
- }
504
- }
505
- return ports;
506
- }
507
- async function nextVuePreviewPort(root, blueprint) {
508
- const usedPorts = await usedPlaywrightPorts(root, blueprint);
509
- let port = 4173;
510
- while (usedPorts.has(port)) {
511
- port += 1;
512
- }
513
- return port;
514
- }
515
- function vueAppPlaywrightConfig(previewPort) {
516
- return `import { defineConfig, devices } from "@playwright/test";
517
-
518
- const previewUrl = "http://127.0.0.1:${previewPort}";
519
-
520
- export default defineConfig({
521
- testDir: "./test/e2e",
522
- use: {
523
- baseURL: previewUrl,
524
- trace: "on-first-retry"
525
- },
526
- webServer: {
527
- command: "pnpm run preview --host 127.0.0.1 --port ${previewPort}",
528
- reuseExistingServer: !process.env.CI,
529
- url: previewUrl
530
- },
531
- projects: [
532
- {
533
- name: "chromium",
534
- use: { ...devices["Desktop Chrome"] }
535
- }
536
- ]
537
- });
538
- `;
539
- }
540
- function packageAdditionOperations(packagePath, packageName, nodeVersion) {
541
- return [
542
- {
543
- kind: "writeJson",
544
- to: `${packagePath}/package.json`,
545
- value: {
546
- name: packageName,
547
- version: "0.0.0",
548
- private: true,
549
- type: "module",
550
- imports: {
551
- "#/*": {
552
- default: "./src/*.ts",
553
- types: "./src/*.ts",
554
- },
555
- },
556
- scripts: projectVueAppPackageScripts(),
557
- dependencies: {
558
- "@vueuse/core": "catalog:",
559
- pinia: "catalog:",
560
- vue: "catalog:",
561
- },
562
- devDependencies: {
563
- "@playwright/test": "catalog:",
564
- "@tailwindcss/vite": "catalog:",
565
- "@types/node": "catalog:",
566
- "@types/web-bluetooth": "catalog:",
567
- "@vitejs/plugin-vue": "catalog:",
568
- "@vue/tsconfig": "catalog:",
569
- oxfmt: "catalog:",
570
- oxlint: "catalog:",
571
- tailwindcss: "catalog:",
572
- typescript: "catalog:",
573
- vite: "catalog:",
574
- vitest: "catalog:",
575
- "vue-tsc": "catalog:",
576
- },
577
- engines: {
578
- node: nodeVersion,
579
- },
580
- },
581
- },
582
- {
583
- kind: "writeJson",
584
- to: `${packagePath}/tsconfig.json`,
585
- value: {
586
- files: [],
587
- references: [
588
- { path: "./tsconfig.app.json" },
589
- { path: "./tsconfig.test.json" },
590
- { path: "./tsconfig.node.json" },
591
- ],
592
- },
593
- },
594
- {
595
- kind: "writeJson",
596
- to: `${packagePath}/tsconfig.app.json`,
597
- value: {
598
- extends: "@vue/tsconfig/tsconfig.dom.json",
599
- compilerOptions: {
600
- composite: true,
601
- module: "ESNext",
602
- moduleResolution: "Bundler",
603
- noEmitOnError: true,
604
- skipLibCheck: false,
605
- strict: true,
606
- target: "ES2022",
607
- tsBuildInfoFile: "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
608
- types: ["web-bluetooth"],
609
- },
610
- include: ["env.d.ts", "src/**/*.ts", "src/**/*.vue"],
611
- },
612
- },
613
- {
614
- kind: "writeJson",
615
- to: `${packagePath}/tsconfig.test.json`,
616
- value: {
617
- extends: "./tsconfig.app.json",
618
- compilerOptions: {
619
- lib: ["ESNext", "DOM", "DOM.Iterable"],
620
- tsBuildInfoFile: "./node_modules/.tmp/tsconfig.test.tsbuildinfo",
621
- types: ["node", "vitest/globals", "web-bluetooth"],
622
- },
623
- include: ["env.d.ts", "src/**/*.ts", "src/**/*.vue", "test/**/*.ts"],
624
- },
625
- },
626
- {
627
- kind: "writeJson",
628
- to: `${packagePath}/tsconfig.node.json`,
629
- value: {
630
- compilerOptions: {
631
- composite: true,
632
- module: "ESNext",
633
- moduleResolution: "Bundler",
634
- noEmitOnError: true,
635
- lib: ["ESNext", "DOM", "DOM.Iterable"],
636
- skipLibCheck: false,
637
- strict: true,
638
- target: "ES2022",
639
- tsBuildInfoFile: "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
640
- types: ["node"],
641
- },
642
- include: ["playwright.config.ts", "vite.config.ts", "vitest.config.ts"],
643
- },
644
- },
645
- { kind: "copyFile", from: "env.d.ts", to: `${packagePath}/env.d.ts` },
646
- { kind: "copyFile", from: "index.html", to: `${packagePath}/index.html` },
647
- {
648
- kind: "copyFile",
649
- from: "playwright.config.ts",
650
- to: `${packagePath}/playwright.config.ts`,
651
- },
652
- {
653
- kind: "copyFile",
654
- from: "vite.config.ts",
655
- to: `${packagePath}/vite.config.ts`,
656
- },
657
- {
658
- kind: "copyFile",
659
- from: "vitest.config.ts",
660
- to: `${packagePath}/vitest.config.ts`,
661
- },
662
- { kind: "copyFile", from: "src/App.vue", to: `${packagePath}/src/App.vue` },
663
- { kind: "copyFile", from: "src/main.ts", to: `${packagePath}/src/main.ts` },
664
- {
665
- kind: "copyFile",
666
- from: "src/style.css",
667
- to: `${packagePath}/src/style.css`,
668
- },
669
- {
670
- kind: "copyFile",
671
- from: "src/stores/counter.ts",
672
- to: `${packagePath}/src/stores/counter.ts`,
673
- },
674
- {
675
- kind: "copyFile",
676
- from: "test/app.test.ts",
677
- to: `${packagePath}/test/app.test.ts`,
678
- },
679
- {
680
- kind: "copyFile",
681
- from: "test/e2e/app.spec.ts",
682
- to: `${packagePath}/test/e2e/app.spec.ts`,
683
- },
684
- ];
685
- }
686
- async function packageAdditionPlan({ root, blueprint, packageName, packagePath, nodeVersion, }) {
687
- const [workspaceCollection] = packagePath.split("/");
688
- const previewPort = await nextVuePreviewPort(root, blueprint);
689
- return {
690
- packagePath,
691
- workspacePackageGlob: `${workspaceCollection}/*`,
692
- packageRole: "runtime-service",
693
- packageSourcePreset: "vue-app",
694
- sourceRoot: templateSourceRoot(),
695
- sourceRoots: { sharedOxc: sharedOxcSourceRoot() },
696
- operations: packageAdditionOperations(packagePath, packageName, nodeVersion),
697
- textFiles: [
698
- {
699
- path: `${packagePath}/playwright.config.ts`,
700
- text: vueAppPlaywrightConfig(previewPort),
701
- },
702
- ],
703
- };
704
- }
705
- function templateSourceRoot() {
706
- const projectionDir = path.dirname(fileURLToPath(import.meta.url));
707
- const publishedTemplateRoot = path.join(projectionDir, "..", "..", "..", "templates", "vue-app");
708
- return existsSync(path.join(publishedTemplateRoot, "src", "App.vue"))
709
- ? publishedTemplateRoot
710
- : projectionDir;
711
- }
712
- function sharedOxcSourceRoot() {
713
- const projectionDir = path.dirname(fileURLToPath(import.meta.url));
714
- const publishedSharedRoot = path.join(projectionDir, "..", "..", "..", "templates", "shared", "oxc");
715
- return existsSync(path.join(publishedSharedRoot, "oxfmt.config.ts"))
716
- ? publishedSharedRoot
717
- : path.join(projectionDir, "..", "shared", "oxc");
718
- }
719
- function sharedDevcontainerSourceRoot() {
720
- const projectionDir = path.dirname(fileURLToPath(import.meta.url));
721
- const publishedSharedRoot = path.join(projectionDir, "..", "..", "..", "templates", "shared", "devcontainer");
722
- return existsSync(path.join(publishedSharedRoot, "node-pnpm.Dockerfile"))
723
- ? publishedSharedRoot
724
- : path.join(projectionDir, "..", "shared", "devcontainer");
725
- }
726
- export const vueAppPresetProjection = {
727
- metadata: vueAppPresetMetadata,
728
- capabilities: {
729
- packageAddition: {
730
- planPackageAddition: packageAdditionPlan,
731
- },
732
- },
733
- blueprint: vueAppBlueprint,
734
- project(context) {
735
- const checkPlan = planVueAppRootChecks();
736
- const fixPlan = planVueAppRootFixes();
737
- const packageScripts = projectVueAppRootPackageScripts();
738
- return {
739
- sourceRoot: templateSourceRoot(),
740
- sourceRoots: {
741
- sharedDevcontainer: sharedDevcontainerSourceRoot(),
742
- sharedOxc: sharedOxcSourceRoot(),
743
- },
744
- operations: operationsForVueApp(context, packageScripts, checkPlan),
745
- checkPlan,
746
- fixPlan,
747
- dependencyMaintenancePolicy,
748
- packageScripts,
749
- capabilities: {
750
- rootCheck: true,
751
- fixCommand: true,
752
- githubActions: true,
753
- dependabot: true,
754
- devcontainer: true,
755
- },
756
- };
757
- },
758
- async render({ targetDir, plan }) {
759
- await renderNewProject({
760
- sourceRoot: plan.sourceRoot,
761
- sourceRoots: plan.sourceRoots,
762
- targetRoot: targetDir,
763
- operations: [...plan.operations],
764
- });
765
- },
766
- };