@analogjs/platform 3.0.0-alpha.8 → 3.0.0-alpha.9
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/package.json +5 -13
- package/src/index.d.ts +1 -1
- package/src/index.js +7 -3
- package/src/index.js.map +1 -0
- package/src/lib/clear-client-page-endpoint.js +22 -34
- package/src/lib/clear-client-page-endpoint.js.map +1 -0
- package/src/lib/content/marked/index.js +10 -6
- package/src/lib/content/marked/index.js.map +1 -0
- package/src/lib/content/marked/marked-content-highlighter.js +6 -3
- package/src/lib/content/marked/marked-content-highlighter.js.map +1 -0
- package/src/lib/content/marked/marked-setup.service.js +44 -54
- package/src/lib/content/marked/marked-setup.service.js.map +1 -0
- package/src/lib/content/prism/angular.js +18 -19
- package/src/lib/content/prism/angular.js.map +1 -0
- package/src/lib/content/prism/index.js +10 -7
- package/src/lib/content/prism/index.js.map +1 -0
- package/src/lib/content/prism/prism-highlighter.js +33 -33
- package/src/lib/content/prism/prism-highlighter.js.map +1 -0
- package/src/lib/content/shiki/index.js +19 -28
- package/src/lib/content/shiki/index.js.map +1 -0
- package/src/lib/content/shiki/shiki-highlighter.js +45 -44
- package/src/lib/content/shiki/shiki-highlighter.js.map +1 -0
- package/src/lib/content-plugin.js +155 -222
- package/src/lib/content-plugin.js.map +1 -0
- package/src/lib/deps-plugin.js +71 -78
- package/src/lib/deps-plugin.js.map +1 -0
- package/src/lib/nx-plugin/package.json +2 -4
- package/src/lib/nx-plugin/src/executors/vite/compat.js +7 -7
- package/src/lib/nx-plugin/src/executors/vite/compat.js.map +1 -1
- package/src/lib/nx-plugin/src/executors/vite/schema.d.ts +1 -1
- package/src/lib/nx-plugin/src/executors/vite/vite.impl.js +6 -4
- package/src/lib/nx-plugin/src/executors/vite/vite.impl.js.map +1 -1
- package/src/lib/nx-plugin/src/executors/vite-dev-server/compat.js +7 -7
- package/src/lib/nx-plugin/src/executors/vite-dev-server/compat.js.map +1 -1
- package/src/lib/nx-plugin/src/executors/vite-dev-server/schema.d.ts +1 -1
- package/src/lib/nx-plugin/src/executors/vite-dev-server/vite-dev-server.impl.js +6 -4
- package/src/lib/nx-plugin/src/executors/vite-dev-server/vite-dev-server.impl.js.map +1 -1
- package/src/lib/nx-plugin/src/executors/vitest/compat.js +7 -7
- package/src/lib/nx-plugin/src/executors/vitest/compat.js.map +1 -1
- package/src/lib/nx-plugin/src/executors/vitest/schema.d.ts +1 -1
- package/src/lib/nx-plugin/src/executors/vitest/vitest.impl.js +6 -4
- package/src/lib/nx-plugin/src/executors/vitest/vitest.impl.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/compat.js +7 -7
- package/src/lib/nx-plugin/src/generators/app/compat.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/files/template-angular-v15/src/main.ts__template__ +0 -6
- package/src/lib/nx-plugin/src/generators/app/files/template-angular-v15/vite.config.ts__template__ +0 -8
- package/src/lib/nx-plugin/src/generators/app/files/template-angular-v17/src/app/app.config.ts__template__ +0 -6
- package/src/lib/nx-plugin/src/generators/app/files/template-angular-v17/vite.config.ts__template__ +0 -17
- package/src/lib/nx-plugin/src/generators/app/files/template-angular-v18/src/app/app.config.ts__template__ +0 -6
- package/src/lib/nx-plugin/src/generators/app/files/template-angular-v18/vite.config.ts__template__ +0 -17
- package/src/lib/nx-plugin/src/generators/app/files/template-angular-v19/src/app/app.config.ts__template__ +0 -6
- package/src/lib/nx-plugin/src/generators/app/files/template-angular-v19/vite.config.ts__template__ +0 -8
- package/src/lib/nx-plugin/src/generators/app/generator.js +78 -92
- package/src/lib/nx-plugin/src/generators/app/generator.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/lib/add-analog-dependencies.js +11 -12
- package/src/lib/nx-plugin/src/generators/app/lib/add-analog-dependencies.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/lib/add-analog-project-config.js +72 -81
- package/src/lib/nx-plugin/src/generators/app/lib/add-analog-project-config.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/lib/add-angular-app.js +23 -58
- package/src/lib/nx-plugin/src/generators/app/lib/add-angular-app.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/lib/add-eslint.js +12 -55
- package/src/lib/nx-plugin/src/generators/app/lib/add-eslint.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/lib/add-files.js +15 -16
- package/src/lib/nx-plugin/src/generators/app/lib/add-files.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/lib/add-home-page.js +14 -13
- package/src/lib/nx-plugin/src/generators/app/lib/add-home-page.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/lib/add-tailwind-config.js +17 -29
- package/src/lib/nx-plugin/src/generators/app/lib/add-tailwind-config.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/lib/add-tailwind-helpers.js +59 -95
- package/src/lib/nx-plugin/src/generators/app/lib/add-tailwind-helpers.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/lib/add-vite-plugin.js +8 -44
- package/src/lib/nx-plugin/src/generators/app/lib/add-vite-plugin.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/lib/cleanup-files.js +17 -20
- package/src/lib/nx-plugin/src/generators/app/lib/cleanup-files.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/lib/initialize-analog-workspace.js +59 -105
- package/src/lib/nx-plugin/src/generators/app/lib/initialize-analog-workspace.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/lib/update-index-html.js +14 -18
- package/src/lib/nx-plugin/src/generators/app/lib/update-index-html.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/versions/dependencies.js +35 -54
- package/src/lib/nx-plugin/src/generators/app/versions/dependencies.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/versions/dev-dependencies.js +41 -68
- package/src/lib/nx-plugin/src/generators/app/versions/dev-dependencies.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/versions/minimum-supported-versions.d.ts +0 -1
- package/src/lib/nx-plugin/src/generators/app/versions/minimum-supported-versions.js +9 -11
- package/src/lib/nx-plugin/src/generators/app/versions/minimum-supported-versions.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/versions/nx-dependencies.js +24 -43
- package/src/lib/nx-plugin/src/generators/app/versions/nx-dependencies.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/versions/nx_17_X/versions.d.ts +0 -5
- package/src/lib/nx-plugin/src/generators/app/versions/nx_17_X/versions.js +29 -36
- package/src/lib/nx-plugin/src/generators/app/versions/nx_17_X/versions.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/versions/nx_18_X/versions.d.ts +5 -10
- package/src/lib/nx-plugin/src/generators/app/versions/nx_18_X/versions.js +30 -37
- package/src/lib/nx-plugin/src/generators/app/versions/nx_18_X/versions.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/versions/tailwind-dependencies.js +11 -16
- package/src/lib/nx-plugin/src/generators/app/versions/tailwind-dependencies.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/versions.d.ts +0 -10
- package/src/lib/nx-plugin/src/generators/app/versions.js +28 -42
- package/src/lib/nx-plugin/src/generators/app/versions.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/init/compat.js +7 -7
- package/src/lib/nx-plugin/src/generators/init/compat.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/init/generator.js +54 -65
- package/src/lib/nx-plugin/src/generators/init/generator.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/init/lib/add-analog-dependencies.js +19 -20
- package/src/lib/nx-plugin/src/generators/init/lib/add-analog-dependencies.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/init/lib/update-app-tsconfig.js +20 -21
- package/src/lib/nx-plugin/src/generators/init/lib/update-app-tsconfig.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/init/lib/update-build-target.js +56 -66
- package/src/lib/nx-plugin/src/generators/init/lib/update-build-target.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/init/lib/update-git-ignore.js +12 -11
- package/src/lib/nx-plugin/src/generators/init/lib/update-git-ignore.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/init/lib/update-index-html.js +17 -21
- package/src/lib/nx-plugin/src/generators/init/lib/update-index-html.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/init/lib/update-main.js +12 -15
- package/src/lib/nx-plugin/src/generators/init/lib/update-main.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/init/lib/update-package-json.js +19 -31
- package/src/lib/nx-plugin/src/generators/init/lib/update-package-json.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/init/lib/update-serve-target.js +43 -51
- package/src/lib/nx-plugin/src/generators/init/lib/update-serve-target.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/init/lib/update-test-target.js +27 -34
- package/src/lib/nx-plugin/src/generators/init/lib/update-test-target.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/init/lib/update-test-tsconfig.js +19 -20
- package/src/lib/nx-plugin/src/generators/init/lib/update-test-tsconfig.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/page/generator.js +34 -44
- package/src/lib/nx-plugin/src/generators/page/generator.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/preset/generator.js +11 -43
- package/src/lib/nx-plugin/src/generators/preset/generator.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/setup-vitest/compat.js +7 -7
- package/src/lib/nx-plugin/src/generators/setup-vitest/compat.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/setup-vitest/generator.js +35 -42
- package/src/lib/nx-plugin/src/generators/setup-vitest/generator.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/setup-vitest/lib/add-analog-dependencies.js +7 -7
- package/src/lib/nx-plugin/src/generators/setup-vitest/lib/add-analog-dependencies.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/setup-vitest/lib/update-test-target.js +20 -27
- package/src/lib/nx-plugin/src/generators/setup-vitest/lib/update-test-target.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/setup-vitest/lib/update-tsconfig.js +19 -22
- package/src/lib/nx-plugin/src/generators/setup-vitest/lib/update-tsconfig.js.map +1 -1
- package/src/lib/nx-plugin/src/index.js +0 -2
- package/src/lib/nx-plugin/src/utils/version-utils.js +20 -27
- package/src/lib/nx-plugin/src/utils/version-utils.js.map +1 -1
- package/src/lib/nx-plugin/src/utils/versions/dependencies.js +42 -62
- package/src/lib/nx-plugin/src/utils/versions/dependencies.js.map +1 -1
- package/src/lib/nx-plugin/src/utils/versions/dev-dependencies.js +49 -83
- package/src/lib/nx-plugin/src/utils/versions/dev-dependencies.js.map +1 -1
- package/src/lib/nx-plugin/src/utils/versions/ng_17_X/versions.js +19 -20
- package/src/lib/nx-plugin/src/utils/versions/ng_17_X/versions.js.map +1 -1
- package/src/lib/nx-plugin/src/utils/versions/ng_18_X/versions.js +19 -20
- package/src/lib/nx-plugin/src/utils/versions/ng_18_X/versions.js.map +1 -1
- package/src/lib/nx-plugin/src/utils/versions/ng_19_X/versions.d.ts +5 -5
- package/src/lib/nx-plugin/src/utils/versions/ng_19_X/versions.js +22 -23
- package/src/lib/nx-plugin/src/utils/versions/ng_19_X/versions.js.map +1 -1
- package/src/lib/platform-plugin.js +57 -63
- package/src/lib/platform-plugin.js.map +1 -0
- package/src/lib/router-plugin.js +135 -185
- package/src/lib/router-plugin.js.map +1 -0
- package/src/lib/ssr/inject-html-plugin.js +25 -25
- package/src/lib/ssr/inject-html-plugin.js.map +1 -0
- package/src/lib/ssr/ssr-build-plugin.js +53 -88
- package/src/lib/ssr/ssr-build-plugin.js.map +1 -0
- package/src/lib/utils/rolldown.js +12 -8
- package/src/lib/utils/rolldown.js.map +1 -0
- package/src/server-mode-plugin.js +16 -20
- package/src/server-mode-plugin.js.map +1 -0
- package/README.md +0 -5
- package/src/lib/content/prism/options.js +0 -1
- package/src/lib/content/shiki/options.js +0 -1
- package/src/lib/nx-plugin/README.md +0 -23
- package/src/lib/nx-plugin/src/index.js.map +0 -1
- package/src/lib/options.js +0 -1
|
@@ -1,118 +1,82 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
exports.addTailwindConfigPathToProject = addTailwindConfigPathToProject;
|
|
8
|
-
exports.addTailwindConfigFile = addTailwindConfigFile;
|
|
9
|
-
const semver_1 = require("@nx/devkit/src/utils/semver");
|
|
10
|
-
const tailwind_dependencies_1 = require("../versions/tailwind-dependencies");
|
|
11
|
-
const semver_2 = require("semver");
|
|
12
|
-
const devkit_1 = require("@nx/devkit");
|
|
13
|
-
const node_path_1 = require("node:path");
|
|
1
|
+
import { getTailwindDependencies } from "../versions/tailwind-dependencies.js";
|
|
2
|
+
import { addDependenciesToPackageJson, generateFiles, joinPathFragments, readJson, stripIndents, updateProjectConfiguration } from "@nx/devkit";
|
|
3
|
+
import { lt } from "semver";
|
|
4
|
+
import { relative } from "node:path";
|
|
5
|
+
import { checkAndCleanWithSemver } from "@nx/devkit/src/utils/semver";
|
|
6
|
+
//#region packages/nx-plugin/src/generators/app/lib/add-tailwind-helpers.ts
|
|
14
7
|
function normalizeOptions(options) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
8
|
+
return {
|
|
9
|
+
...options,
|
|
10
|
+
buildTarget: options.buildTarget || "build"
|
|
11
|
+
};
|
|
19
12
|
}
|
|
20
13
|
function detectTailwindInstalledVersion(tree) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
if ((0, semver_2.lt)(version, '4.0.0')) {
|
|
28
|
-
throw new Error(`The Tailwind CSS version "${tailwindVersion}" is not supported. Please upgrade to v4.0.0 or higher.`);
|
|
29
|
-
}
|
|
30
|
-
return (0, semver_2.lt)(version, '5.0.0') ? '4' : '5';
|
|
14
|
+
const { dependencies, devDependencies } = readJson(tree, "package.json");
|
|
15
|
+
const tailwindVersion = dependencies?.tailwindcss ?? devDependencies?.tailwindcss;
|
|
16
|
+
if (!tailwindVersion) return;
|
|
17
|
+
const version = checkAndCleanWithSemver("tailwindcss", tailwindVersion);
|
|
18
|
+
if (lt(version, "4.0.0")) throw new Error(`The Tailwind CSS version "${tailwindVersion}" is not supported. Please upgrade to v4.0.0 or higher.`);
|
|
19
|
+
return lt(version, "5.0.0") ? "4" : "5";
|
|
31
20
|
}
|
|
32
21
|
function addTailwindRequiredPackages(tree) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
22
|
+
const pkgVersions = getTailwindDependencies();
|
|
23
|
+
return addDependenciesToPackageJson(tree, {
|
|
24
|
+
postcss: pkgVersions.postcss,
|
|
25
|
+
tailwindcss: pkgVersions.tailwindcss,
|
|
26
|
+
"@tailwindcss/postcss": pkgVersions["@tailwindcss/postcss"]
|
|
27
|
+
}, {});
|
|
39
28
|
}
|
|
40
29
|
function updateApplicationStyles(tree, options, project) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
stylesEntryPoint = findStylesEntryPoint(tree, options, project);
|
|
47
|
-
if (!stylesEntryPoint) {
|
|
48
|
-
throw new Error((0, devkit_1.stripIndents) `Could not find a styles entry point for project "${options.project}".
|
|
30
|
+
let stylesEntryPoint = options.stylesEntryPoint;
|
|
31
|
+
if (stylesEntryPoint && !tree.exists(stylesEntryPoint)) throw new Error(`The provided styles entry point "${stylesEntryPoint}" could not be found.`);
|
|
32
|
+
if (!stylesEntryPoint) {
|
|
33
|
+
stylesEntryPoint = findStylesEntryPoint(tree, options, project);
|
|
34
|
+
if (!stylesEntryPoint) throw new Error(stripIndents`Could not find a styles entry point for project "${options.project}".
|
|
49
35
|
Please specify a styles entry point using the "--stylesEntryPoint" option.`);
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
const stylesEntryPointContent = tree.read(stylesEntryPoint, 'utf-8');
|
|
56
|
-
tree.write(stylesEntryPoint, (0, devkit_1.stripIndents) `@import "tailwindcss";
|
|
36
|
+
}
|
|
37
|
+
if (!stylesEntryPoint.endsWith(".css")) throw new Error(`Tailwind CSS v4 is not compatible with any css preprocessors like sass or less. Please use a css file as the styles entry point.`);
|
|
38
|
+
const stylesEntryPointContent = tree.read(stylesEntryPoint, "utf-8");
|
|
39
|
+
tree.write(stylesEntryPoint, stripIndents`@import "tailwindcss";
|
|
57
40
|
|
|
58
41
|
|
|
59
42
|
${stylesEntryPointContent}`);
|
|
60
43
|
}
|
|
61
44
|
function findStylesEntryPoint(tree, options, project) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
const styles = project.targets?.[options.buildTarget].options?.styles;
|
|
75
|
-
if (!styles) {
|
|
76
|
-
return undefined;
|
|
77
|
-
}
|
|
78
|
-
// find the first style that belongs to the project source
|
|
79
|
-
const style = styles.find((s) => typeof s === 'string'
|
|
80
|
-
? s.startsWith(project.root) && tree.exists(s)
|
|
81
|
-
: s.input.startsWith(project.root) &&
|
|
82
|
-
s.inject !== false &&
|
|
83
|
-
tree.exists(s.input));
|
|
84
|
-
if (!style) {
|
|
85
|
-
return undefined;
|
|
86
|
-
}
|
|
87
|
-
return typeof style === 'string' ? style : style.input;
|
|
45
|
+
const stylesEntryPoint = [
|
|
46
|
+
joinPathFragments(project.sourceRoot ?? project.root, "styles.css"),
|
|
47
|
+
joinPathFragments(project.sourceRoot ?? project.root, "styles.scss"),
|
|
48
|
+
joinPathFragments(project.sourceRoot ?? project.root, "styles.sass"),
|
|
49
|
+
joinPathFragments(project.sourceRoot ?? project.root, "styles.less")
|
|
50
|
+
].find((s) => tree.exists(s));
|
|
51
|
+
if (stylesEntryPoint) return stylesEntryPoint;
|
|
52
|
+
const styles = project.targets?.[options.buildTarget].options?.styles;
|
|
53
|
+
if (!styles) return;
|
|
54
|
+
const style = styles.find((s) => typeof s === "string" ? s.startsWith(project.root) && tree.exists(s) : s.input.startsWith(project.root) && s.inject !== false && tree.exists(s.input));
|
|
55
|
+
if (!style) return;
|
|
56
|
+
return typeof style === "string" ? style : style.input;
|
|
88
57
|
}
|
|
89
58
|
function addTailwindConfigPathToProject(tree, options, project) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
throw new Error((0, devkit_1.stripIndents) `The target "${options.buildTarget}" was not found for project "${options.project}".
|
|
59
|
+
const buildTarget = project.targets?.[options.buildTarget];
|
|
60
|
+
if (!buildTarget) throw new Error(stripIndents`The target "${options.buildTarget}" was not found for project "${options.project}".
|
|
93
61
|
If you are using a different build target, please provide it using the "--buildTarget" option.
|
|
94
62
|
If the project is not a buildable or publishable library, you don't need to setup TailwindCSS for it.`);
|
|
95
|
-
|
|
96
|
-
if (buildTarget.options?.tailwindConfig &&
|
|
97
|
-
tree.exists(buildTarget.options.tailwindConfig)) {
|
|
98
|
-
throw new Error((0, devkit_1.stripIndents) `The "${buildTarget.options.tailwindConfig}" file is already configured for the project "${options.project}". Are you sure this is the right project to set up Tailwind?
|
|
63
|
+
if (buildTarget.options?.tailwindConfig && tree.exists(buildTarget.options.tailwindConfig)) throw new Error(stripIndents`The "${buildTarget.options.tailwindConfig}" file is already configured for the project "${options.project}". Are you sure this is the right project to set up Tailwind?
|
|
99
64
|
If you are sure, you can remove the configuration and re-run the generator.`);
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
(0, devkit_1.updateProjectConfiguration)(tree, options.project, project);
|
|
65
|
+
buildTarget.options = {
|
|
66
|
+
...buildTarget.options,
|
|
67
|
+
tailwindConfig: joinPathFragments(project.root, "tailwind.config.ts")
|
|
68
|
+
};
|
|
69
|
+
updateProjectConfiguration(tree, options.project, project);
|
|
106
70
|
}
|
|
107
71
|
function addTailwindConfigFile(tree, options, project) {
|
|
108
|
-
|
|
109
|
-
tree.exists((0, devkit_1.joinPathFragments)(project.root, 'tailwind.config.js'))) {
|
|
110
|
-
throw new Error((0, devkit_1.stripIndents) `The "tailwind.config" file already exists in the project "${options.project}". Are you sure this is the right project to set up Tailwind?
|
|
72
|
+
if (tree.exists(joinPathFragments(project.root, "tailwind.config.ts")) || tree.exists(joinPathFragments(project.root, "tailwind.config.js"))) throw new Error(stripIndents`The "tailwind.config" file already exists in the project "${options.project}". Are you sure this is the right project to set up Tailwind?
|
|
111
73
|
If you are sure, you can remove the existing file and re-run the generator.`);
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
});
|
|
74
|
+
generateFiles(tree, joinPathFragments(__dirname, "..", "files", "tailwind/v4"), project.root, {
|
|
75
|
+
relativeSourceRoot: relative(project.root, project.sourceRoot ?? project.root),
|
|
76
|
+
template: ""
|
|
77
|
+
});
|
|
117
78
|
}
|
|
79
|
+
//#endregion
|
|
80
|
+
export { addTailwindConfigFile, addTailwindConfigPathToProject, addTailwindRequiredPackages, detectTailwindInstalledVersion, normalizeOptions, updateApplicationStyles };
|
|
81
|
+
|
|
118
82
|
//# sourceMappingURL=add-tailwind-helpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-tailwind-helpers.js","
|
|
1
|
+
{"version":3,"file":"add-tailwind-helpers.js","names":[],"sources":["../../../../../../../../../../packages/nx-plugin/src/generators/app/lib/add-tailwind-helpers.ts"],"sourcesContent":["import { checkAndCleanWithSemver } from '@nx/devkit/src/utils/semver';\nimport { getTailwindDependencies } from '../versions/tailwind-dependencies';\nimport { lt } from 'semver';\nimport {\n Tree,\n readJson,\n addDependenciesToPackageJson,\n GeneratorCallback,\n ProjectConfiguration,\n joinPathFragments,\n stripIndents,\n updateProjectConfiguration,\n generateFiles,\n} from '@nx/devkit';\nimport {\n GeneratorOptions,\n NormalizedGeneratorOptions,\n} from './add-tailwind-config';\nimport { relative } from 'node:path';\n\nexport function normalizeOptions(\n options: GeneratorOptions,\n): NormalizedGeneratorOptions {\n return {\n ...options,\n buildTarget: options.buildTarget || 'build',\n };\n}\n\nexport function detectTailwindInstalledVersion(\n tree: Tree,\n): '4' | '5' | undefined {\n const { dependencies, devDependencies } = readJson(tree, 'package.json');\n const tailwindVersion =\n dependencies?.tailwindcss ?? devDependencies?.tailwindcss;\n\n if (!tailwindVersion) {\n return undefined;\n }\n\n const version = checkAndCleanWithSemver('tailwindcss', tailwindVersion);\n if (lt(version, '4.0.0')) {\n throw new Error(\n `The Tailwind CSS version \"${tailwindVersion}\" is not supported. Please upgrade to v4.0.0 or higher.`,\n );\n }\n return lt(version, '5.0.0') ? '4' : '5';\n}\n\nexport function addTailwindRequiredPackages(tree: Tree): GeneratorCallback {\n const pkgVersions = getTailwindDependencies();\n return addDependenciesToPackageJson(\n tree,\n {\n postcss: pkgVersions.postcss,\n tailwindcss: pkgVersions.tailwindcss,\n '@tailwindcss/postcss': pkgVersions['@tailwindcss/postcss'],\n },\n {},\n );\n}\n\nexport function updateApplicationStyles(\n tree: Tree,\n options: NormalizedGeneratorOptions,\n project: ProjectConfiguration,\n): void {\n let stylesEntryPoint = options.stylesEntryPoint;\n\n if (stylesEntryPoint && !tree.exists(stylesEntryPoint)) {\n throw new Error(\n `The provided styles entry point \"${stylesEntryPoint}\" could not be found.`,\n );\n }\n\n if (!stylesEntryPoint) {\n stylesEntryPoint = findStylesEntryPoint(tree, options, project);\n\n if (!stylesEntryPoint) {\n throw new Error(\n stripIndents`Could not find a styles entry point for project \"${options.project}\".\n Please specify a styles entry point using the \"--stylesEntryPoint\" option.`,\n );\n }\n }\n\n if (!stylesEntryPoint.endsWith('.css')) {\n throw new Error(\n `Tailwind CSS v4 is not compatible with any css preprocessors like sass or less. Please use a css file as the styles entry point.`,\n );\n }\n\n const stylesEntryPointContent = tree.read(stylesEntryPoint, 'utf-8');\n\n tree.write(\n stylesEntryPoint,\n stripIndents`@import \"tailwindcss\";\n\n\n ${stylesEntryPointContent}`,\n );\n}\n\nfunction findStylesEntryPoint(\n tree: Tree,\n options: NormalizedGeneratorOptions,\n project: ProjectConfiguration,\n): string | undefined {\n // first check for common names\n const possibleStylesEntryPoints = [\n joinPathFragments(project.sourceRoot ?? project.root, 'styles.css'),\n joinPathFragments(project.sourceRoot ?? project.root, 'styles.scss'),\n joinPathFragments(project.sourceRoot ?? project.root, 'styles.sass'),\n joinPathFragments(project.sourceRoot ?? project.root, 'styles.less'),\n ];\n\n const stylesEntryPoint = possibleStylesEntryPoints.find((s) =>\n tree.exists(s),\n );\n if (stylesEntryPoint) {\n return stylesEntryPoint;\n }\n\n // then check for the specified styles in the build configuration if it exists\n const styles: Array<string | { input: string; inject: boolean }> =\n project.targets?.[options.buildTarget].options?.styles;\n\n if (!styles) {\n return undefined;\n }\n\n // find the first style that belongs to the project source\n const style = styles.find((s) =>\n typeof s === 'string'\n ? s.startsWith(project.root) && tree.exists(s)\n : s.input.startsWith(project.root) &&\n s.inject !== false &&\n tree.exists(s.input),\n );\n\n if (!style) {\n return undefined;\n }\n\n return typeof style === 'string' ? style : style.input;\n}\n\nexport function addTailwindConfigPathToProject(\n tree: Tree,\n options: NormalizedGeneratorOptions,\n project: ProjectConfiguration,\n): void {\n const buildTarget = project.targets?.[options.buildTarget];\n\n if (!buildTarget) {\n throw new Error(\n stripIndents`The target \"${options.buildTarget}\" was not found for project \"${options.project}\".\n If you are using a different build target, please provide it using the \"--buildTarget\" option.\n If the project is not a buildable or publishable library, you don't need to setup TailwindCSS for it.`,\n );\n }\n\n if (\n buildTarget.options?.tailwindConfig &&\n tree.exists(buildTarget.options.tailwindConfig)\n ) {\n throw new Error(\n stripIndents`The \"${buildTarget.options.tailwindConfig}\" file is already configured for the project \"${options.project}\". Are you sure this is the right project to set up Tailwind?\n If you are sure, you can remove the configuration and re-run the generator.`,\n );\n }\n\n buildTarget.options = {\n ...buildTarget.options,\n tailwindConfig: joinPathFragments(project.root, 'tailwind.config.ts'),\n };\n\n updateProjectConfiguration(tree, options.project, project);\n}\n\nexport function addTailwindConfigFile(\n tree: Tree,\n options: GeneratorOptions,\n project: ProjectConfiguration,\n): void {\n if (\n tree.exists(joinPathFragments(project.root, 'tailwind.config.ts')) ||\n tree.exists(joinPathFragments(project.root, 'tailwind.config.js'))\n ) {\n throw new Error(\n stripIndents`The \"tailwind.config\" file already exists in the project \"${options.project}\". Are you sure this is the right project to set up Tailwind?\n If you are sure, you can remove the existing file and re-run the generator.`,\n );\n }\n\n generateFiles(\n tree,\n joinPathFragments(__dirname, '..', 'files', 'tailwind/v4'),\n project.root,\n {\n relativeSourceRoot: relative(\n project.root,\n project.sourceRoot ?? project.root,\n ),\n template: '',\n },\n );\n}\n"],"mappings":"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"}
|
|
@@ -1,47 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.initVite = initVite;
|
|
1
|
+
//#region packages/nx-plugin/src/generators/app/lib/add-vite-plugin.ts
|
|
37
2
|
async function initVite(tree) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
await (await Promise.resolve().then(() => __importStar(require(
|
|
43
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
44
|
-
// @ts-ignore
|
|
45
|
-
'@nx/vite')))).initGenerator(tree, linterOptions);
|
|
3
|
+
await (await import("@nx/vite")).initGenerator(tree, {
|
|
4
|
+
addPlugin: true,
|
|
5
|
+
skipFormat: true
|
|
6
|
+
});
|
|
46
7
|
}
|
|
8
|
+
//#endregion
|
|
9
|
+
export { initVite };
|
|
10
|
+
|
|
47
11
|
//# sourceMappingURL=add-vite-plugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-vite-plugin.js","
|
|
1
|
+
{"version":3,"file":"add-vite-plugin.js","names":[],"sources":["../../../../../../../../../../packages/nx-plugin/src/generators/app/lib/add-vite-plugin.ts"],"sourcesContent":["import { Tree } from '@nx/devkit';\n\nexport async function initVite(tree: Tree): Promise<void> {\n const linterOptions = {\n addPlugin: true,\n skipFormat: true,\n };\n await (\n await import(\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n '@nx/vite'\n )\n ).initGenerator(tree, linterOptions);\n}\n"],"mappings":";AAEA,eAAsB,SAAS,MAA2B;AAKxD,QACE,MAAM,OAGJ,aAEF,cAAc,MAVM;EACpB,WAAW;EACX,YAAY;EACb,CAOmC"}
|
|
@@ -1,23 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.cleanupFiles = cleanupFiles;
|
|
1
|
+
//#region packages/nx-plugin/src/generators/app/lib/cleanup-files.ts
|
|
4
2
|
function cleanupFiles(tree, options) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
if (tree.exists(filePath)) {
|
|
19
|
-
tree.delete(filePath);
|
|
20
|
-
}
|
|
21
|
-
});
|
|
3
|
+
const files = [
|
|
4
|
+
"src/app/app.component.css",
|
|
5
|
+
"src/app/app.component.html",
|
|
6
|
+
"src/app/app.routes.ts",
|
|
7
|
+
"src/app/nx-welcome.component.ts",
|
|
8
|
+
"src/index.html",
|
|
9
|
+
"vite.config.mts"
|
|
10
|
+
];
|
|
11
|
+
if (!options.isNx) files.push("project.json");
|
|
12
|
+
files.forEach((file) => {
|
|
13
|
+
const filePath = `${options.projectRoot}/${file}`;
|
|
14
|
+
if (tree.exists(filePath)) tree.delete(filePath);
|
|
15
|
+
});
|
|
22
16
|
}
|
|
17
|
+
//#endregion
|
|
18
|
+
export { cleanupFiles };
|
|
19
|
+
|
|
23
20
|
//# sourceMappingURL=cleanup-files.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cleanup-files.js","
|
|
1
|
+
{"version":3,"file":"cleanup-files.js","names":[],"sources":["../../../../../../../../../../packages/nx-plugin/src/generators/app/lib/cleanup-files.ts"],"sourcesContent":["import { Tree } from '@nx/devkit';\nimport { NormalizedOptions } from '../generator';\n\nexport function cleanupFiles(tree: Tree, options: NormalizedOptions): void {\n const files = [\n 'src/app/app.component.css',\n 'src/app/app.component.html',\n 'src/app/app.routes.ts',\n 'src/app/nx-welcome.component.ts',\n 'src/index.html',\n 'vite.config.mts',\n ];\n\n if (!options.isNx) {\n files.push('project.json');\n }\n\n files.forEach((file) => {\n const filePath = `${options.projectRoot}/${file}`;\n if (tree.exists(filePath)) {\n tree.delete(filePath);\n }\n });\n}\n"],"mappings":";AAGA,SAAgB,aAAa,MAAY,SAAkC;CACzE,MAAM,QAAQ;EACZ;EACA;EACA;EACA;EACA;EACA;EACD;AAED,KAAI,CAAC,QAAQ,KACX,OAAM,KAAK,eAAe;AAG5B,OAAM,SAAS,SAAS;EACtB,MAAM,WAAW,GAAG,QAAQ,YAAY,GAAG;AAC3C,MAAI,KAAK,OAAO,SAAS,CACvB,MAAK,OAAO,SAAS;GAEvB"}
|
|
@@ -1,110 +1,64 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.initializeAngularWorkspace = initializeAngularWorkspace;
|
|
37
|
-
const semver_1 = require("semver");
|
|
38
|
-
const devkit_1 = require("@nx/devkit");
|
|
39
|
-
const version_utils_1 = require("../../../utils/version-utils");
|
|
40
|
-
const minimum_supported_versions_1 = require("../versions/minimum-supported-versions");
|
|
41
|
-
const nx_dependencies_1 = require("../versions/nx-dependencies");
|
|
1
|
+
import { getInstalledPackageVersion } from "../../../utils/version-utils.js";
|
|
2
|
+
import { belowMinimumSupportedAngularVersion } from "../versions/minimum-supported-versions.js";
|
|
3
|
+
import { getNrwlDependencies, getNxDependencies } from "../versions/nx-dependencies.js";
|
|
4
|
+
import { addDependenciesToPackageJson, ensurePackage, stripIndents } from "@nx/devkit";
|
|
5
|
+
import { major } from "semver";
|
|
6
|
+
//#region packages/nx-plugin/src/generators/app/lib/initialize-analog-workspace.ts
|
|
42
7
|
async function initializeAngularWorkspace(tree, installedNxVersion, normalizedOptions) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
if (!angularVersion) {
|
|
54
|
-
throw new Error('Could not determine installed Angular version.');
|
|
55
|
-
}
|
|
56
|
-
if ((0, minimum_supported_versions_1.belowMinimumSupportedAngularVersion)(angularVersion)) {
|
|
57
|
-
throw new Error((0, devkit_1.stripIndents) `Analog only supports an Angular version of 15 and higher`);
|
|
58
|
-
}
|
|
59
|
-
return angularVersion;
|
|
8
|
+
let angularVersion = getInstalledPackageVersion(tree, "@angular/core");
|
|
9
|
+
if (!angularVersion) {
|
|
10
|
+
console.log("Angular has not been installed yet. Creating an Angular application");
|
|
11
|
+
if (major(installedNxVersion) >= 16) angularVersion = await initWithNxNamespace(tree, installedNxVersion, normalizedOptions.skipFormat);
|
|
12
|
+
else angularVersion = await initWithNrwlNamespace(tree, installedNxVersion, normalizedOptions.skipFormat);
|
|
13
|
+
}
|
|
14
|
+
if (!angularVersion) throw new Error("Could not determine installed Angular version.");
|
|
15
|
+
if (belowMinimumSupportedAngularVersion(angularVersion)) throw new Error(stripIndents`Analog only supports an Angular version of 15 and higher`);
|
|
16
|
+
return angularVersion;
|
|
60
17
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
18
|
+
var initWithNxNamespace = async (tree, installedNxVersion, skipFormat = true) => {
|
|
19
|
+
const versions = getNxDependencies(installedNxVersion);
|
|
20
|
+
addDependenciesToPackageJson(tree, {
|
|
21
|
+
"@angular/animations": "^19.0.0",
|
|
22
|
+
"@angular/common": "^19.0.0",
|
|
23
|
+
"@angular/compiler": "^19.0.0",
|
|
24
|
+
"@angular/core": "^19.0.0",
|
|
25
|
+
"@angular/forms": "^19.0.0",
|
|
26
|
+
"@angular/platform-browser": "^19.0.0",
|
|
27
|
+
"@angular/platform-browser-dynamic": "^19.0.0",
|
|
28
|
+
"@angular/platform-server": "^19.0.0",
|
|
29
|
+
"@angular/router": "^19.0.0",
|
|
30
|
+
rxjs: "~7.8.0",
|
|
31
|
+
tslib: "^2.4.0",
|
|
32
|
+
"zone.js": "~0.15.0"
|
|
33
|
+
}, {
|
|
34
|
+
"@angular-devkit/build-angular": "^19.0.0",
|
|
35
|
+
"@angular/compiler-cli": "^19.0.0",
|
|
36
|
+
"@nx/angular": versions["@nx/angular"],
|
|
37
|
+
"@nx/devkit": versions["@nx/devkit"],
|
|
38
|
+
"@nx/eslint": versions["@nx/eslint"],
|
|
39
|
+
typescript: "~5.7.0"
|
|
40
|
+
});
|
|
41
|
+
return getInstalledPackageVersion(tree, "@angular/core", void 0, true);
|
|
85
42
|
};
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
// @ts-ignore
|
|
104
|
-
'@nrwl/angular/generators')))).angularInitGenerator(tree, {
|
|
105
|
-
skipInstall: true,
|
|
106
|
-
skipFormat: skipFormat,
|
|
107
|
-
});
|
|
108
|
-
return (0, version_utils_1.getInstalledPackageVersion)(tree, '@angular/core', undefined, true);
|
|
43
|
+
var initWithNrwlNamespace = async (tree, installedNxVersion, skipFormat = true) => {
|
|
44
|
+
const versions = getNrwlDependencies(installedNxVersion);
|
|
45
|
+
try {
|
|
46
|
+
ensurePackage("@nrwl/devkit", versions["@nrwl/devkit"]);
|
|
47
|
+
ensurePackage("@nrwl/angular", versions["@nrwl/angular"]);
|
|
48
|
+
ensurePackage("@nrwl/linter", versions["@nrwl/linter"]);
|
|
49
|
+
} catch {}
|
|
50
|
+
addDependenciesToPackageJson(tree, {}, {
|
|
51
|
+
"@nrwl/devkit": versions["@nrwl/devkit"],
|
|
52
|
+
"@nrwl/angular": versions["@nrwl/angular"],
|
|
53
|
+
"@nrwl/linter": versions["@nrwl/linter"]
|
|
54
|
+
});
|
|
55
|
+
await (await import("@nrwl/angular/generators")).angularInitGenerator(tree, {
|
|
56
|
+
skipInstall: true,
|
|
57
|
+
skipFormat
|
|
58
|
+
});
|
|
59
|
+
return getInstalledPackageVersion(tree, "@angular/core", void 0, true);
|
|
109
60
|
};
|
|
61
|
+
//#endregion
|
|
62
|
+
export { initializeAngularWorkspace };
|
|
63
|
+
|
|
110
64
|
//# sourceMappingURL=initialize-analog-workspace.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initialize-analog-workspace.js","
|
|
1
|
+
{"version":3,"file":"initialize-analog-workspace.js","names":[],"sources":["../../../../../../../../../../packages/nx-plugin/src/generators/app/lib/initialize-analog-workspace.ts"],"sourcesContent":["import { major } from 'semver';\nimport {\n addDependenciesToPackageJson,\n ensurePackage,\n stripIndents,\n Tree,\n} from '@nx/devkit';\nimport { getInstalledPackageVersion } from '../../../utils/version-utils';\nimport { NormalizedOptions } from '../generator';\nimport { belowMinimumSupportedAngularVersion } from '../versions/minimum-supported-versions';\nimport {\n getNrwlDependencies,\n getNxDependencies,\n} from '../versions/nx-dependencies';\n\nexport async function initializeAngularWorkspace(\n tree: Tree,\n installedNxVersion: string,\n normalizedOptions: NormalizedOptions,\n): Promise<string> {\n let angularVersion = getInstalledPackageVersion(tree, '@angular/core');\n\n if (!angularVersion) {\n console.log(\n 'Angular has not been installed yet. Creating an Angular application',\n );\n\n if (major(installedNxVersion) >= 16) {\n angularVersion = await initWithNxNamespace(\n tree,\n installedNxVersion,\n normalizedOptions.skipFormat,\n );\n } else {\n angularVersion = await initWithNrwlNamespace(\n tree,\n installedNxVersion,\n normalizedOptions.skipFormat,\n );\n }\n }\n\n if (!angularVersion) {\n throw new Error('Could not determine installed Angular version.');\n }\n\n if (belowMinimumSupportedAngularVersion(angularVersion)) {\n throw new Error(\n stripIndents`Analog only supports an Angular version of 15 and higher`,\n );\n }\n\n return angularVersion;\n}\n\nconst initWithNxNamespace = async (\n tree: Tree,\n installedNxVersion: string,\n skipFormat = true,\n) => {\n const versions = getNxDependencies(installedNxVersion);\n\n addDependenciesToPackageJson(\n tree,\n {\n '@angular/animations': '^19.0.0',\n '@angular/common': '^19.0.0',\n '@angular/compiler': '^19.0.0',\n '@angular/core': '^19.0.0',\n '@angular/forms': '^19.0.0',\n '@angular/platform-browser': '^19.0.0',\n '@angular/platform-browser-dynamic': '^19.0.0',\n '@angular/platform-server': '^19.0.0',\n '@angular/router': '^19.0.0',\n rxjs: '~7.8.0',\n tslib: '^2.4.0',\n 'zone.js': '~0.15.0',\n },\n {\n '@angular-devkit/build-angular': '^19.0.0',\n '@angular/compiler-cli': '^19.0.0',\n '@nx/angular': versions['@nx/angular'],\n '@nx/devkit': versions['@nx/devkit'],\n '@nx/eslint': versions['@nx/eslint'],\n typescript: '~5.7.0',\n },\n );\n\n return getInstalledPackageVersion(tree, '@angular/core', undefined, true);\n};\n\nconst initWithNrwlNamespace = async (\n tree: Tree,\n installedNxVersion: string,\n skipFormat = true,\n) => {\n const versions = getNrwlDependencies(installedNxVersion);\n try {\n ensurePackage('@nrwl/devkit', versions['@nrwl/devkit']);\n ensurePackage('@nrwl/angular', versions['@nrwl/angular']);\n ensurePackage('@nrwl/linter', versions['@nrwl/linter']);\n } catch {\n // @nx/angular cannot be required so this fails but this will still allow executing the nx angular init later on\n }\n addDependenciesToPackageJson(\n tree,\n {},\n {\n '@nrwl/devkit': versions['@nrwl/devkit'],\n '@nrwl/angular': versions['@nrwl/angular'],\n '@nrwl/linter': versions['@nrwl/linter'],\n },\n );\n await (\n await import(\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n '@nrwl/angular/generators'\n )\n ).angularInitGenerator(tree, {\n skipInstall: true,\n skipFormat: skipFormat,\n });\n return getInstalledPackageVersion(tree, '@angular/core', undefined, true);\n};\n"],"mappings":";;;;;;AAeA,eAAsB,2BACpB,MACA,oBACA,mBACiB;CACjB,IAAI,iBAAiB,2BAA2B,MAAM,gBAAgB;AAEtE,KAAI,CAAC,gBAAgB;AACnB,UAAQ,IACN,sEACD;AAED,MAAI,MAAM,mBAAmB,IAAI,GAC/B,kBAAiB,MAAM,oBACrB,MACA,oBACA,kBAAkB,WACnB;MAED,kBAAiB,MAAM,sBACrB,MACA,oBACA,kBAAkB,WACnB;;AAIL,KAAI,CAAC,eACH,OAAM,IAAI,MAAM,iDAAiD;AAGnE,KAAI,oCAAoC,eAAe,CACrD,OAAM,IAAI,MACR,YAAY,2DACb;AAGH,QAAO;;AAGT,IAAM,sBAAsB,OAC1B,MACA,oBACA,aAAa,SACV;CACH,MAAM,WAAW,kBAAkB,mBAAmB;AAEtD,8BACE,MACA;EACE,uBAAuB;EACvB,mBAAmB;EACnB,qBAAqB;EACrB,iBAAiB;EACjB,kBAAkB;EAClB,6BAA6B;EAC7B,qCAAqC;EACrC,4BAA4B;EAC5B,mBAAmB;EACnB,MAAM;EACN,OAAO;EACP,WAAW;EACZ,EACD;EACE,iCAAiC;EACjC,yBAAyB;EACzB,eAAe,SAAS;EACxB,cAAc,SAAS;EACvB,cAAc,SAAS;EACvB,YAAY;EACb,CACF;AAED,QAAO,2BAA2B,MAAM,iBAAiB,KAAA,GAAW,KAAK;;AAG3E,IAAM,wBAAwB,OAC5B,MACA,oBACA,aAAa,SACV;CACH,MAAM,WAAW,oBAAoB,mBAAmB;AACxD,KAAI;AACF,gBAAc,gBAAgB,SAAS,gBAAgB;AACvD,gBAAc,iBAAiB,SAAS,iBAAiB;AACzD,gBAAc,gBAAgB,SAAS,gBAAgB;SACjD;AAGR,8BACE,MACA,EAAE,EACF;EACE,gBAAgB,SAAS;EACzB,iBAAiB,SAAS;EAC1B,gBAAgB,SAAS;EAC1B,CACF;AACD,QACE,MAAM,OAGJ,6BAEF,qBAAqB,MAAM;EAC3B,aAAa;EACD;EACb,CAAC;AACF,QAAO,2BAA2B,MAAM,iBAAiB,KAAA,GAAW,KAAK"}
|
|
@@ -1,22 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.updateIndex = updateIndex;
|
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
|
1
|
+
import { getProjects, joinPathFragments } from "@nx/devkit";
|
|
2
|
+
//#region packages/nx-plugin/src/generators/app/lib/update-index-html.ts
|
|
5
3
|
function updateIndex(tree, projectName) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const indexContents = tree.read(indexPath, 'utf-8');
|
|
14
|
-
if (!indexContents) {
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
const updatedIndex = indexContents.replace('</head>', `<link rel="stylesheet" href="/src/styles.css" />
|
|
4
|
+
const projectConfig = getProjects(tree).get(projectName);
|
|
5
|
+
if (!projectConfig) return;
|
|
6
|
+
const indexPath = joinPathFragments(projectConfig.root, "index.html");
|
|
7
|
+
if (tree.exists(indexPath)) {
|
|
8
|
+
const indexContents = tree.read(indexPath, "utf-8");
|
|
9
|
+
if (!indexContents) return;
|
|
10
|
+
const updatedIndex = indexContents.replace("</head>", `<link rel="stylesheet" href="/src/styles.css" />
|
|
18
11
|
</head>`);
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
tree.write(indexPath, updatedIndex);
|
|
13
|
+
}
|
|
21
14
|
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { updateIndex };
|
|
17
|
+
|
|
22
18
|
//# sourceMappingURL=update-index-html.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-index-html.js","
|
|
1
|
+
{"version":3,"file":"update-index-html.js","names":[],"sources":["../../../../../../../../../../packages/nx-plugin/src/generators/app/lib/update-index-html.ts"],"sourcesContent":["import { Tree, getProjects, joinPathFragments } from '@nx/devkit';\n\nexport function updateIndex(tree: Tree, projectName: string): void {\n const projects = getProjects(tree);\n const projectConfig = projects.get(projectName);\n if (!projectConfig) {\n return;\n }\n\n const indexPath = joinPathFragments(projectConfig.root, 'index.html');\n\n if (tree.exists(indexPath)) {\n const indexContents = tree.read(indexPath, 'utf-8');\n if (!indexContents) {\n return;\n }\n const updatedIndex = indexContents.replace(\n '</head>',\n `<link rel=\"stylesheet\" href=\"/src/styles.css\" />\n </head>`,\n );\n\n tree.write(indexPath, updatedIndex);\n }\n}\n"],"mappings":";;AAEA,SAAgB,YAAY,MAAY,aAA2B;CAEjE,MAAM,gBADW,YAAY,KAAK,CACH,IAAI,YAAY;AAC/C,KAAI,CAAC,cACH;CAGF,MAAM,YAAY,kBAAkB,cAAc,MAAM,aAAa;AAErE,KAAI,KAAK,OAAO,UAAU,EAAE;EAC1B,MAAM,gBAAgB,KAAK,KAAK,WAAW,QAAQ;AACnD,MAAI,CAAC,cACH;EAEF,MAAM,eAAe,cAAc,QACjC,WACA;eAED;AAED,OAAK,MAAM,WAAW,aAAa"}
|