@analogjs/vite-plugin-angular 3.0.0-beta.2 → 3.0.0-beta.4
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 +40 -0
- package/migrations/migrate-setup-vitest/migrate-setup-vitest.js +13 -2
- package/migrations/migrate-setup-vitest/migrate-setup-vitest.js.map +1 -1
- package/package.json +1 -14
- package/src/lib/tools/src/builders/vite/vite-build.impl.js +2 -1
- package/src/lib/tools/src/builders/vite/vite-build.impl.js.map +1 -1
- package/migrations/migrations.json +0 -9
- package/migrations/update-3-0-0/migrate-setup-vitest.d.ts +0 -2
- package/migrations/update-3-0-0/migrate-setup-vitest.js +0 -37
- package/migrations/update-3-0-0/migrate-setup-vitest.js.map +0 -1
package/README.md
CHANGED
|
@@ -50,6 +50,46 @@ export default defineConfig({
|
|
|
50
50
|
|
|
51
51
|
> The `angular` plugin should be listed **first** in the plugins array.
|
|
52
52
|
|
|
53
|
+
## Plugin Options
|
|
54
|
+
|
|
55
|
+
All options are optional.
|
|
56
|
+
|
|
57
|
+
| Option | Default | Description |
|
|
58
|
+
| ----------------------- | ----------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
59
|
+
| `tsconfig` | `tsconfig.app.json` | Path to the tsconfig used for compilation, or a function returning it. Libraries default to `tsconfig.lib.json` and tests to `tsconfig.spec.json`. |
|
|
60
|
+
| `workspaceRoot` | `NX_WORKSPACE_ROOT`, then `process.cwd()` | Absolute path to the workspace root. Set it in monorepos where the app is not the working directory. |
|
|
61
|
+
| `inlineStylesExtension` | `'css'` | Stylesheet language for inline component `styles`, such as `'scss'`. See [CSS Pre-processors](https://analogjs.org/docs/packages/vite-plugin-angular/css-preprocessors). |
|
|
62
|
+
| `jit` | `true` in tests, `false` otherwise | Compile components in JIT mode instead of AOT. |
|
|
63
|
+
| `include` | `[]` | Additional globs, relative to the workspace root, to add to compilation, such as components from a library outside the tsconfig `include`. |
|
|
64
|
+
| `liveReload` | `true` | Enables Angular component HMR during development. This is separate from Vite's `server.hmr` transport option. |
|
|
65
|
+
| `disableTypeChecking` | `true` | Skips semantic and template diagnostics during compilation. Set to `false` to report type errors from the Vite build. |
|
|
66
|
+
| `fileReplacements` | `[]` | Replaces source files at build time, like `fileReplacements` in `angular.json`. Use `{ replace, with }`, or `{ replace, ssr }` for the SSR build. `with` and `ssr` paths resolve against `workspaceRoot`. |
|
|
67
|
+
| `fastCompile` | `false` | Opts into the [fast compile path](#fast-compile-mode). |
|
|
68
|
+
| `fastCompileMode` | `'full'` | Output mode for `fastCompile`: `'full'` for apps, `'partial'` for publishing libraries. |
|
|
69
|
+
| `debug` | `false` | Enables `analog:angular:*` debug logging. |
|
|
70
|
+
|
|
71
|
+
```ts
|
|
72
|
+
import { defineConfig } from 'vite';
|
|
73
|
+
import angular from '@analogjs/vite-plugin-angular';
|
|
74
|
+
|
|
75
|
+
export default defineConfig(({ mode }) => ({
|
|
76
|
+
plugins: [
|
|
77
|
+
angular({
|
|
78
|
+
inlineStylesExtension: 'scss',
|
|
79
|
+
fileReplacements:
|
|
80
|
+
mode === 'production'
|
|
81
|
+
? [
|
|
82
|
+
{
|
|
83
|
+
replace: 'src/environments/environment.ts',
|
|
84
|
+
with: 'src/environments/environment.prod.ts',
|
|
85
|
+
},
|
|
86
|
+
]
|
|
87
|
+
: [],
|
|
88
|
+
}),
|
|
89
|
+
],
|
|
90
|
+
}));
|
|
91
|
+
```
|
|
92
|
+
|
|
53
93
|
## Fast Compile Mode
|
|
54
94
|
|
|
55
95
|
`fastCompile` opts the plugin into a single-pass compilation path that emits Ivy instructions directly and skips Angular's template type-checking. It's intended for content-focused apps and faster dev iteration where build throughput matters more than inline type-safety feedback.
|
|
@@ -1,7 +1,17 @@
|
|
|
1
|
-
import { NodePackageInstallTask } from "@angular-devkit/schematics/tasks";
|
|
1
|
+
import { NodePackageInstallTask } from "@angular-devkit/schematics/tasks/index.js";
|
|
2
2
|
//#region packages/vite-plugin-angular/migrations/migrate-setup-vitest/migrate-setup-vitest.ts
|
|
3
3
|
var OLD_IMPORT = "@analogjs/vite-plugin-angular/setup-vitest";
|
|
4
4
|
var NEW_IMPORT = "@analogjs/vitest-angular/setup-zone";
|
|
5
|
+
var SUPPORTED_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
6
|
+
".cjs",
|
|
7
|
+
".cts",
|
|
8
|
+
".js",
|
|
9
|
+
".jsx",
|
|
10
|
+
".mjs",
|
|
11
|
+
".mts",
|
|
12
|
+
".ts",
|
|
13
|
+
".tsx"
|
|
14
|
+
]);
|
|
5
15
|
function addVitestAngularDependency(tree, context) {
|
|
6
16
|
const pkgPath = "/package.json";
|
|
7
17
|
const content = tree.read(pkgPath);
|
|
@@ -24,7 +34,8 @@ function migrateSetupVitest() {
|
|
|
24
34
|
return (tree, context) => {
|
|
25
35
|
const filesToUpdate = [];
|
|
26
36
|
tree.visit((filePath) => {
|
|
27
|
-
|
|
37
|
+
const extension = filePath.slice(filePath.lastIndexOf("."));
|
|
38
|
+
if (!SUPPORTED_EXTENSIONS.has(extension)) return;
|
|
28
39
|
if (filePath.includes("/node_modules/")) return;
|
|
29
40
|
const content = tree.read(filePath);
|
|
30
41
|
if (!content) return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrate-setup-vitest.js","names":[],"sources":["../../../migrations/migrate-setup-vitest/migrate-setup-vitest.ts"],"sourcesContent":["import { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';\nimport { NodePackageInstallTask } from '@angular-devkit/schematics/tasks';\n\nconst OLD_IMPORT = '@analogjs/vite-plugin-angular/setup-vitest';\nconst NEW_IMPORT = '@analogjs/vitest-angular/setup-zone';\n\nfunction addVitestAngularDependency(\n tree: Tree,\n context: SchematicContext,\n): void {\n const pkgPath = '/package.json';\n const content = tree.read(pkgPath);\n if (!content) {\n return;\n }\n\n const pkg = JSON.parse(content.toString('utf-8'));\n const devDeps = pkg['devDependencies'] || {};\n const deps = pkg['dependencies'] || {};\n\n if (\n !devDeps['@analogjs/vitest-angular'] &&\n !deps['@analogjs/vitest-angular']\n ) {\n const analogVersion =\n devDeps['@analogjs/vite-plugin-angular'] ||\n deps['@analogjs/vite-plugin-angular'] ||\n '*';\n\n pkg['devDependencies'] = {\n ...devDeps,\n '@analogjs/vitest-angular': analogVersion,\n };\n\n tree.overwrite(pkgPath, JSON.stringify(pkg, null, 2) + '\\n');\n context.addTask(new NodePackageInstallTask());\n context.logger.info(\n `Added '@analogjs/vitest-angular': '${analogVersion}' to devDependencies.`,\n );\n }\n}\n\nexport default function migrateSetupVitest(): Rule {\n return (tree: Tree, context: SchematicContext) => {\n const filesToUpdate: string[] = [];\n\n tree.visit((filePath) => {\n
|
|
1
|
+
{"version":3,"file":"migrate-setup-vitest.js","names":[],"sources":["../../../migrations/migrate-setup-vitest/migrate-setup-vitest.ts"],"sourcesContent":["import { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';\nimport { NodePackageInstallTask } from '@angular-devkit/schematics/tasks/index.js';\n\nconst OLD_IMPORT = '@analogjs/vite-plugin-angular/setup-vitest';\nconst NEW_IMPORT = '@analogjs/vitest-angular/setup-zone';\nconst SUPPORTED_EXTENSIONS = new Set([\n '.cjs',\n '.cts',\n '.js',\n '.jsx',\n '.mjs',\n '.mts',\n '.ts',\n '.tsx',\n]);\n\nfunction addVitestAngularDependency(\n tree: Tree,\n context: SchematicContext,\n): void {\n const pkgPath = '/package.json';\n const content = tree.read(pkgPath);\n if (!content) {\n return;\n }\n\n const pkg = JSON.parse(content.toString('utf-8'));\n const devDeps = pkg['devDependencies'] || {};\n const deps = pkg['dependencies'] || {};\n\n if (\n !devDeps['@analogjs/vitest-angular'] &&\n !deps['@analogjs/vitest-angular']\n ) {\n const analogVersion =\n devDeps['@analogjs/vite-plugin-angular'] ||\n deps['@analogjs/vite-plugin-angular'] ||\n '*';\n\n pkg['devDependencies'] = {\n ...devDeps,\n '@analogjs/vitest-angular': analogVersion,\n };\n\n tree.overwrite(pkgPath, JSON.stringify(pkg, null, 2) + '\\n');\n context.addTask(new NodePackageInstallTask());\n context.logger.info(\n `Added '@analogjs/vitest-angular': '${analogVersion}' to devDependencies.`,\n );\n }\n}\n\nexport default function migrateSetupVitest(): Rule {\n return (tree: Tree, context: SchematicContext) => {\n const filesToUpdate: string[] = [];\n\n tree.visit((filePath) => {\n const extension = filePath.slice(filePath.lastIndexOf('.'));\n if (!SUPPORTED_EXTENSIONS.has(extension)) {\n return;\n }\n if (filePath.includes('/node_modules/')) {\n return;\n }\n\n const content = tree.read(filePath);\n if (!content) {\n return;\n }\n\n const text = content.toString('utf-8');\n if (text.includes(OLD_IMPORT)) {\n const updated = text.replace(\n new RegExp(OLD_IMPORT.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'), 'g'),\n NEW_IMPORT,\n );\n tree.overwrite(filePath, updated);\n filesToUpdate.push(filePath);\n }\n });\n\n if (filesToUpdate.length > 0) {\n context.logger.info(\n `Migrated ${filesToUpdate.length} file(s) from '${OLD_IMPORT}' to '${NEW_IMPORT}':`,\n );\n for (const file of filesToUpdate) {\n context.logger.info(` - ${file}`);\n }\n }\n\n if (filesToUpdate.length > 0) {\n addVitestAngularDependency(tree, context);\n }\n\n return tree;\n };\n}\n"],"mappings":";;AAGA,IAAM,aAAa;AACnB,IAAM,aAAa;AACnB,IAAM,uCAAuB,IAAI,IAAI;CACnC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,SAAS,2BACP,MACA,SACM;CACN,MAAM,UAAU;CAChB,MAAM,UAAU,KAAK,KAAK,OAAO;CACjC,IAAI,CAAC,SACH;CAGF,MAAM,MAAM,KAAK,MAAM,QAAQ,SAAS,OAAO,CAAC;CAChD,MAAM,UAAU,IAAI,sBAAsB,CAAC;CAC3C,MAAM,OAAO,IAAI,mBAAmB,CAAC;CAErC,IACE,CAAC,QAAQ,+BACT,CAAC,KAAK,6BACN;EACA,MAAM,gBACJ,QAAQ,oCACR,KAAK,oCACL;EAEF,IAAI,qBAAqB;GACvB,GAAG;GACH,4BAA4B;EAC9B;EAEA,KAAK,UAAU,SAAS,KAAK,UAAU,KAAK,MAAM,CAAC,IAAI,IAAI;EAC3D,QAAQ,QAAQ,IAAI,uBAAuB,CAAC;EAC5C,QAAQ,OAAO,KACb,sCAAsC,cAAc,sBACtD;CACF;AACF;AAEA,SAAwB,qBAA2B;CACjD,QAAQ,MAAY,YAA8B;EAChD,MAAM,gBAA0B,CAAC;EAEjC,KAAK,OAAO,aAAa;GACvB,MAAM,YAAY,SAAS,MAAM,SAAS,YAAY,GAAG,CAAC;GAC1D,IAAI,CAAC,qBAAqB,IAAI,SAAS,GACrC;GAEF,IAAI,SAAS,SAAS,gBAAgB,GACpC;GAGF,MAAM,UAAU,KAAK,KAAK,QAAQ;GAClC,IAAI,CAAC,SACH;GAGF,MAAM,OAAO,QAAQ,SAAS,OAAO;GACrC,IAAI,KAAK,SAAS,UAAU,GAAG;IAC7B,MAAM,UAAU,KAAK,QACnB,IAAI,OAAO,WAAW,QAAQ,uBAAuB,MAAM,GAAG,GAAG,GACjE,UACF;IACA,KAAK,UAAU,UAAU,OAAO;IAChC,cAAc,KAAK,QAAQ;GAC7B;EACF,CAAC;EAED,IAAI,cAAc,SAAS,GAAG;GAC5B,QAAQ,OAAO,KACb,YAAY,cAAc,OAAO,iBAAiB,WAAW,QAAQ,WAAW,GAClF;GACA,KAAK,MAAM,QAAQ,eACjB,QAAQ,OAAO,KAAK,OAAO,MAAM;EAErC;EAEA,IAAI,cAAc,SAAS,GACzB,2BAA2B,MAAM,OAAO;EAG1C,OAAO;CACT;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@analogjs/vite-plugin-angular",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.4",
|
|
4
4
|
"description": "Vite Plugin for Angular",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -57,18 +57,6 @@
|
|
|
57
57
|
"tinyglobby": "^0.2.15"
|
|
58
58
|
},
|
|
59
59
|
"builders": "./src/lib/tools/builders.json",
|
|
60
|
-
"nx-migrations": {
|
|
61
|
-
"packageGroup": [
|
|
62
|
-
"@analogjs/platform",
|
|
63
|
-
"@analogjs/content",
|
|
64
|
-
"@analogjs/router",
|
|
65
|
-
"@analogjs/storybook-angular",
|
|
66
|
-
"@analogjs/vite-plugin-angular",
|
|
67
|
-
"@analogjs/vite-plugin-nitro",
|
|
68
|
-
"@analogjs/vitest-angular"
|
|
69
|
-
],
|
|
70
|
-
"migrations": "./migrations/migrations.json"
|
|
71
|
-
},
|
|
72
60
|
"ng-update": {
|
|
73
61
|
"packageGroup": [
|
|
74
62
|
"@analogjs/platform",
|
|
@@ -83,7 +71,6 @@
|
|
|
83
71
|
},
|
|
84
72
|
"exports": {
|
|
85
73
|
"./package.json": "./package.json",
|
|
86
|
-
"./migrations.json": "./migrations/migrations.json",
|
|
87
74
|
".": {
|
|
88
75
|
"types": "./src/index.d.ts",
|
|
89
76
|
"import": "./src/index.js",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
let _angular_devkit_architect = require("@angular-devkit/architect");
|
|
2
|
+
let node_path = require("node:path");
|
|
2
3
|
//#region packages/vite-plugin-angular-tools/src/builders/vite/vite-build.impl.ts
|
|
3
4
|
async function viteBuilder(options, context) {
|
|
4
5
|
const { createBuilder } = await Function("return import(\"vite\")")();
|
|
@@ -18,7 +19,7 @@ async function viteBuilder(options, context) {
|
|
|
18
19
|
root: projectConfig.root,
|
|
19
20
|
mode,
|
|
20
21
|
build: {
|
|
21
|
-
outDir: options.outputPath,
|
|
22
|
+
outDir: options.outputPath ? (0, node_path.resolve)(context.workspaceRoot, options.outputPath) : void 0,
|
|
22
23
|
sourcemap: !!buildOptions.sourcemap
|
|
23
24
|
}
|
|
24
25
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite-build.impl.js","names":[],"sources":["../../../../../../../../vite-plugin-angular-tools/src/builders/vite/vite-build.impl.ts"],"sourcesContent":["import {\n BuilderContext,\n BuilderOutput,\n createBuilder,\n targetFromTargetString,\n} from '@angular-devkit/architect';\nimport type { InlineConfig } from 'vite';\nimport { ViteBuildSchema } from './schema';\n\nasync function viteBuilder(\n options: ViteBuildSchema,\n context: BuilderContext,\n): Promise<BuilderOutput> {\n const { createBuilder } = await Function('return import(\"vite\")')();\n if (!context.target) {\n throw new Error('Builder must be executed with a target');\n }\n const projectConfig = await context.getProjectMetadata(context.target);\n const projectName = context.target.project;\n const configuration = context.target.configuration || 'production';\n const buildTargetSpecifier = `::${configuration}`;\n const buildTarget = targetFromTargetString(\n buildTargetSpecifier,\n projectName,\n 'build',\n );\n\n const browserBuilderName = await context.getBuilderNameForTarget(buildTarget);\n const rawBuildOptions = await context.getTargetOptions(buildTarget);\n const buildOptions = await context.validateOptions(\n rawBuildOptions,\n browserBuilderName,\n );\n\n // Explicit build options and the requested configuration win over an\n // ambient NODE_ENV, so `build:production` cannot silently produce a\n // development build when NODE_ENV happens to be set. See #2458.\n const mode = (buildOptions.mode ?? configuration) as string;\n\n if (process.env.NODE_ENV && process.env.NODE_ENV !== mode) {\n context.logger.warn(\n `NODE_ENV is set to \"${process.env.NODE_ENV}\" but is ignored because the build resolved mode \"${mode}\" from the build options and configuration.`,\n );\n }\n\n const buildConfig: InlineConfig = {\n configFile: options.configFile,\n root: projectConfig.root as string,\n mode,\n build: {\n outDir: options.outputPath,\n sourcemap: !!buildOptions.sourcemap,\n },\n };\n\n try {\n const builder = await createBuilder(buildConfig, false);\n await builder.buildApp();\n\n return {\n success: true,\n };\n } catch (e) {\n console.error(e);\n return {\n success: false,\n };\n }\n}\n\nexport default createBuilder(viteBuilder) as any;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"vite-build.impl.js","names":[],"sources":["../../../../../../../../vite-plugin-angular-tools/src/builders/vite/vite-build.impl.ts"],"sourcesContent":["import {\n BuilderContext,\n BuilderOutput,\n createBuilder,\n targetFromTargetString,\n} from '@angular-devkit/architect';\nimport { resolve } from 'node:path';\nimport type { InlineConfig } from 'vite';\nimport { ViteBuildSchema } from './schema';\n\nasync function viteBuilder(\n options: ViteBuildSchema,\n context: BuilderContext,\n): Promise<BuilderOutput> {\n const { createBuilder } = await Function('return import(\"vite\")')();\n if (!context.target) {\n throw new Error('Builder must be executed with a target');\n }\n const projectConfig = await context.getProjectMetadata(context.target);\n const projectName = context.target.project;\n const configuration = context.target.configuration || 'production';\n const buildTargetSpecifier = `::${configuration}`;\n const buildTarget = targetFromTargetString(\n buildTargetSpecifier,\n projectName,\n 'build',\n );\n\n const browserBuilderName = await context.getBuilderNameForTarget(buildTarget);\n const rawBuildOptions = await context.getTargetOptions(buildTarget);\n const buildOptions = await context.validateOptions(\n rawBuildOptions,\n browserBuilderName,\n );\n\n // Explicit build options and the requested configuration win over an\n // ambient NODE_ENV, so `build:production` cannot silently produce a\n // development build when NODE_ENV happens to be set. See #2458.\n const mode = (buildOptions.mode ?? configuration) as string;\n\n if (process.env.NODE_ENV && process.env.NODE_ENV !== mode) {\n context.logger.warn(\n `NODE_ENV is set to \"${process.env.NODE_ENV}\" but is ignored because the build resolved mode \"${mode}\" from the build options and configuration.`,\n );\n }\n\n const buildConfig: InlineConfig = {\n configFile: options.configFile,\n root: projectConfig.root as string,\n mode,\n build: {\n // outputPath is workspace-relative; Vite resolves a relative outDir\n // against the project root.\n outDir: options.outputPath\n ? resolve(context.workspaceRoot, options.outputPath)\n : undefined,\n sourcemap: !!buildOptions.sourcemap,\n },\n };\n\n try {\n const builder = await createBuilder(buildConfig, false);\n await builder.buildApp();\n\n return {\n success: true,\n };\n } catch (e) {\n console.error(e);\n return {\n success: false,\n };\n }\n}\n\nexport default createBuilder(viteBuilder) as any;\n"],"mappings":";;;AAUA,eAAe,YACb,SACA,SACwB;CACxB,MAAM,EAAE,kBAAkB,MAAM,SAAS,yBAAuB,CAAC,CAAC;CAClE,IAAI,CAAC,QAAQ,QACX,MAAM,IAAI,MAAM,wCAAwC;CAE1D,MAAM,gBAAgB,MAAM,QAAQ,mBAAmB,QAAQ,MAAM;CACrE,MAAM,cAAc,QAAQ,OAAO;CACnC,MAAM,gBAAgB,QAAQ,OAAO,iBAAiB;CACtD,MAAM,uBAAuB,KAAK;CAClC,MAAM,eAAA,GAAc,0BAAA,uBAAA,CAClB,sBACA,aACA,OACF;CAEA,MAAM,qBAAqB,MAAM,QAAQ,wBAAwB,WAAW;CAC5E,MAAM,kBAAkB,MAAM,QAAQ,iBAAiB,WAAW;CAClE,MAAM,eAAe,MAAM,QAAQ,gBACjC,iBACA,kBACF;CAKA,MAAM,OAAQ,aAAa,QAAQ;CAEnC,IAAA,QAAA,IAAA,YAAA,QAAA,IAAA,aAAqD,MACnD,QAAQ,OAAO,KACb,uBAAA,QAAA,IAAA,SAA4C,oDAAoD,KAAK,4CACvG;CAGF,MAAM,cAA4B;EAChC,YAAY,QAAQ;EACpB,MAAM,cAAc;EACpB;EACA,OAAO;GAGL,QAAQ,QAAQ,cAAA,GACZ,UAAA,QAAA,CAAQ,QAAQ,eAAe,QAAQ,UAAU,IACjD,KAAA;GACJ,WAAW,CAAC,CAAC,aAAa;EAC5B;CACF;CAEA,IAAI;EAEF,OAAM,MADgB,cAAc,aAAa,KAAK,EAAA,CACxC,SAAS;EAEvB,OAAO,EACL,SAAS,KACX;CACF,SAAS,GAAG;EACV,QAAQ,MAAM,CAAC;EACf,OAAO,EACL,SAAS,MACX;CACF;AACF;AAEA,IAAA,2BAAA,GAAe,0BAAA,cAAA,CAAc,WAAW"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"generators": {
|
|
3
|
-
"update-3-0-0-migrate-setup-vitest": {
|
|
4
|
-
"version": "3.0.0-alpha.25",
|
|
5
|
-
"description": "Migrate from @analogjs/vite-plugin-angular/setup-vitest to @analogjs/vitest-angular/setup-zone in Nx workspaces",
|
|
6
|
-
"implementation": "./update-3-0-0/migrate-setup-vitest"
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { addDependenciesToPackageJson, readJson, runTasksInSerial, visitNotIgnoredFiles } from "@nx/devkit";
|
|
2
|
-
//#region packages/vite-plugin-angular/migrations/update-3-0-0/migrate-setup-vitest.ts
|
|
3
|
-
var OLD_IMPORT = "@analogjs/vite-plugin-angular/setup-vitest";
|
|
4
|
-
var NEW_IMPORT = "@analogjs/vitest-angular/setup-zone";
|
|
5
|
-
var SUPPORTED_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
6
|
-
".cjs",
|
|
7
|
-
".cts",
|
|
8
|
-
".js",
|
|
9
|
-
".jsx",
|
|
10
|
-
".mjs",
|
|
11
|
-
".mts",
|
|
12
|
-
".ts",
|
|
13
|
-
".tsx"
|
|
14
|
-
]);
|
|
15
|
-
function getAnalogVersion(tree) {
|
|
16
|
-
if (!tree.exists("package.json")) return "*";
|
|
17
|
-
const packageJson = readJson(tree, "package.json");
|
|
18
|
-
return packageJson.devDependencies?.["@analogjs/vite-plugin-angular"] || packageJson.dependencies?.["@analogjs/vite-plugin-angular"] || "*";
|
|
19
|
-
}
|
|
20
|
-
async function migrateSetupVitest(tree) {
|
|
21
|
-
const filesToUpdate = [];
|
|
22
|
-
visitNotIgnoredFiles(tree, "", (filePath) => {
|
|
23
|
-
const extension = filePath.slice(filePath.lastIndexOf("."));
|
|
24
|
-
if (!SUPPORTED_EXTENSIONS.has(extension)) return;
|
|
25
|
-
const content = tree.read(filePath, "utf-8");
|
|
26
|
-
if (!content?.includes(OLD_IMPORT)) return;
|
|
27
|
-
tree.write(filePath, content.replaceAll(OLD_IMPORT, NEW_IMPORT));
|
|
28
|
-
filesToUpdate.push(filePath);
|
|
29
|
-
});
|
|
30
|
-
if (filesToUpdate.length === 0) return;
|
|
31
|
-
const installTask = addDependenciesToPackageJson(tree, {}, { "@analogjs/vitest-angular": getAnalogVersion(tree) }, "package.json", true);
|
|
32
|
-
return runTasksInSerial(installTask);
|
|
33
|
-
}
|
|
34
|
-
//#endregion
|
|
35
|
-
export { migrateSetupVitest as default };
|
|
36
|
-
|
|
37
|
-
//# sourceMappingURL=migrate-setup-vitest.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"migrate-setup-vitest.js","names":[],"sources":["../../../migrations/update-3-0-0/migrate-setup-vitest.ts"],"sourcesContent":["import {\n addDependenciesToPackageJson,\n readJson,\n runTasksInSerial,\n Tree,\n visitNotIgnoredFiles,\n} from '@nx/devkit';\n\nconst OLD_IMPORT = '@analogjs/vite-plugin-angular/setup-vitest';\nconst NEW_IMPORT = '@analogjs/vitest-angular/setup-zone';\nconst SUPPORTED_EXTENSIONS = new Set([\n '.cjs',\n '.cts',\n '.js',\n '.jsx',\n '.mjs',\n '.mts',\n '.ts',\n '.tsx',\n]);\n\nfunction getAnalogVersion(tree: Tree): string {\n if (!tree.exists('package.json')) {\n return '*';\n }\n\n const packageJson = readJson<{\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n }>(tree, 'package.json');\n\n return (\n packageJson.devDependencies?.['@analogjs/vite-plugin-angular'] ||\n packageJson.dependencies?.['@analogjs/vite-plugin-angular'] ||\n '*'\n );\n}\n\nexport default async function migrateSetupVitest(tree: Tree) {\n const filesToUpdate: string[] = [];\n\n visitNotIgnoredFiles(tree, '', (filePath) => {\n const extension = filePath.slice(filePath.lastIndexOf('.'));\n if (!SUPPORTED_EXTENSIONS.has(extension)) {\n return;\n }\n\n const content = tree.read(filePath, 'utf-8');\n if (!content?.includes(OLD_IMPORT)) {\n return;\n }\n\n tree.write(filePath, content.replaceAll(OLD_IMPORT, NEW_IMPORT));\n filesToUpdate.push(filePath);\n });\n\n if (filesToUpdate.length === 0) {\n return;\n }\n\n const installTask = addDependenciesToPackageJson(\n tree,\n {},\n {\n '@analogjs/vitest-angular': getAnalogVersion(tree),\n },\n 'package.json',\n true,\n );\n\n return runTasksInSerial(installTask);\n}\n"],"mappings":";;AAQA,IAAM,aAAa;AACnB,IAAM,aAAa;AACnB,IAAM,uCAAuB,IAAI,IAAI;CACnC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,SAAS,iBAAiB,MAAoB;CAC5C,IAAI,CAAC,KAAK,OAAO,cAAc,GAC7B,OAAO;CAGT,MAAM,cAAc,SAGjB,MAAM,cAAc;CAEvB,OACE,YAAY,kBAAkB,oCAC9B,YAAY,eAAe,oCAC3B;AAEJ;AAEA,eAA8B,mBAAmB,MAAY;CAC3D,MAAM,gBAA0B,CAAC;CAEjC,qBAAqB,MAAM,KAAK,aAAa;EAC3C,MAAM,YAAY,SAAS,MAAM,SAAS,YAAY,GAAG,CAAC;EAC1D,IAAI,CAAC,qBAAqB,IAAI,SAAS,GACrC;EAGF,MAAM,UAAU,KAAK,KAAK,UAAU,OAAO;EAC3C,IAAI,CAAC,SAAS,SAAS,UAAU,GAC/B;EAGF,KAAK,MAAM,UAAU,QAAQ,WAAW,YAAY,UAAU,CAAC;EAC/D,cAAc,KAAK,QAAQ;CAC7B,CAAC;CAED,IAAI,cAAc,WAAW,GAC3B;CAGF,MAAM,cAAc,6BAClB,MACA,CAAC,GACD,EACE,4BAA4B,iBAAiB,IAAI,EACnD,GACA,gBACA,IACF;CAEA,OAAO,iBAAiB,WAAW;AACrC"}
|