Skip to content

Commit

Permalink
fix(nx-plugin): adjust templates/docs for adding Analog to existing A…
Browse files Browse the repository at this point in the history
…ngular projects (#1090)
  • Loading branch information
brandonroberts committed May 13, 2024
1 parent a970d0c commit 474081a
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 5 deletions.
6 changes: 3 additions & 3 deletions apps/docs-app/docs/guides/migrating.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,23 @@ First, install the `@analogjs/platform` package:
<TabItem value="npm">

```shell
npm install @analogjs/platform --save-dev
npm install @analogjs/platform nx@18 --save-dev
```

</TabItem>

<TabItem label="Yarn" value="yarn">

```shell
yarn add @analogjs/platform --dev
yarn add @analogjs/platform nx@18 --dev
```

</TabItem>

<TabItem value="pnpm">

```shell
pnpm install -w @analogjs/platform
pnpm install -w @analogjs/platform nx@18
```

</TabItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export default defineConfig(({ mode }) => {
build: {
outDir: '<%= offsetFromRoot %>dist/<%= projectRoot %>/client',
reportCompressedSize: true,
commonjsOptions: { transformMixedEsModules: true },
target: ['es2020'],
},
plugins: [
Expand Down
14 changes: 14 additions & 0 deletions packages/nx-plugin/src/utils/versions/dependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ import {
V17_X_ANALOG_JS_ROUTER,
V17_X_NX_ANGULAR,
} from './ng_17_X/versions';
import {
V15_X_ANALOG_JS_CONTENT,
V15_X_ANALOG_JS_ROUTER,
V15_X_NX_ANGULAR,
} from './ng_15_X/versions';

const dependencyKeys = [
'@analogjs/content',
Expand All @@ -34,6 +39,15 @@ const getDependencies = (escapedAngularVersion: string) => {
throw new Error(stripIndents`Angular v15.0.0 or newer is required.`);
}

// install 15.x deps for versions <16.0.0
if (lt(escapedAngularVersion, '16.0.0')) {
return {
'@analogjs/content': V15_X_ANALOG_JS_CONTENT,
'@analogjs/router': V15_X_ANALOG_JS_ROUTER,
'@nx/angular': V15_X_NX_ANGULAR,
};
}

// install 16.x deps for versions <17.0.0
if (lt(escapedAngularVersion, '17.0.0')) {
return {
Expand Down
22 changes: 21 additions & 1 deletion packages/nx-plugin/src/utils/versions/dev-dependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ import {
V17_X_VITE_TSCONFIG_PATHS,
V17_X_VITEST,
} from './ng_17_X/versions';
import {
V15_X_ANALOG_JS_PLATFORM,
V15_X_ANALOG_JS_VITE_PLUGIN_ANGULAR,
V15_X_NX_VITE,
V15_X_JSDOM,
V15_X_VITE_TSCONFIG_PATHS,
V15_X_VITEST,
} from './ng_15_X/versions';

const devDependencyKeys = [
'@analogjs/platform',
Expand All @@ -40,7 +48,19 @@ export const getAnalogDevDependencies = (
const getDevDependencies = (escapedAngularVersion: string) => {
// fail out for versions <15.2.0
if (lt(escapedAngularVersion, '15.0.0')) {
throw new Error(stripIndents`Angular v16.0.0 or newer is required.`);
throw new Error(stripIndents`Angular v15.0.0 or newer is required.`);
}

// install 15.x deps for versions <15.0.0
if (lt(escapedAngularVersion, '16.0.0')) {
return {
'@analogjs/platform': V15_X_ANALOG_JS_PLATFORM,
'@analogjs/vite-plugin-angular': V15_X_ANALOG_JS_VITE_PLUGIN_ANGULAR,
'@nx/vite': V15_X_NX_VITE,
jsdom: V15_X_JSDOM,
'vite-tsconfig-paths': V15_X_VITE_TSCONFIG_PATHS,
vitest: V15_X_VITEST,
};
}

// install 16.x deps for versions <17.0.0
Expand Down
12 changes: 12 additions & 0 deletions packages/nx-plugin/src/utils/versions/ng_15_X/versions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// V15_X
export const V15_X_ANALOG_JS_ROUTER = '~1.1.0';
export const V15_X_ANALOG_JS_CONTENT = '~1.1.0';

// devDependencies
export const V15_X_ANALOG_JS_PLATFORM = '^1.3.0';
export const V15_X_ANALOG_JS_VITE_PLUGIN_ANGULAR = '^1.3.0';
export const V15_X_NX_ANGULAR = '~18.0.0';
export const V15_X_NX_VITE = '~18.0.0';
export const V15_X_JSDOM = '^22.0.0';
export const V15_X_VITE_TSCONFIG_PATHS = '^4.2.0';
export const V15_X_VITEST = '^1.3.1';

0 comments on commit 474081a

Please sign in to comment.