Skip to content

Commit

Permalink
fix(transloco): 🐛 Angular 17 ng-add
Browse files Browse the repository at this point in the history
Closes: #729
  • Loading branch information
shaharkazaz committed Dec 5, 2023
1 parent 4e16a04 commit b69f61e
Show file tree
Hide file tree
Showing 33 changed files with 50 additions and 3,060 deletions.
6 changes: 3 additions & 3 deletions docs/docs/schematics/upgrade.mdx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
---
title: Upgrade
description: Schematics - Upgrade | Transloco Angular i18n
description: Schematics - Upgrade [Legacy] | Transloco Angular i18n
---

## Upgrade
## Upgrade [Legacy and will be removed in v7]

### Overview

The Library's upgrade script from lower versions. For more information about the script see:
The Library's upgrade script from v1 to v2. For more information about the script see:
[v2-upgrade.md](https://github.com/ngneat/transloco/tree/master/libs/transloco-schematics/src/upgrade/v2-upgrade.md)

### Command
Expand Down
20 changes: 10 additions & 10 deletions libs/transloco-schematics/src/collection.json
Original file line number Diff line number Diff line change
@@ -1,57 +1,57 @@
{
"extends": ["@schematics/angular"],
"$schema": "../../../../@angular-devkit/schematics/collection-schema.json",
"$schema": "../../../node_modules/@angular-devkit/schematics/collection-schema.json",
"schematics": {
"ng-add": {
"aliases": ["init"],
"factory": "./ng-add/",
"factory": "./ng-add/index",
"schema": "./ng-add/schema.json",
"description": "Add transloco configuration for root module."
},
"component": {
"aliases": ["c"],
"factory": "./component/",
"factory": "./component/index",
"schema": "../../../../@schematics/angular/component/schema.json",
"description": "Add component with translation."
},
"migrate": {
"aliases": ["m"],
"factory": "./migrate/",
"factory": "./migrate/index",
"schema": "./migrate/schema.json",
"description": "Run a migration script from @ngx-translate."
},
"scope": {
"aliases": ["s"],
"factory": "./scope/",
"factory": "./scope/index",
"schema": "./scope/schema.json",
"description": "Add transloco scope."
},
"upgrade": {
"aliases": ["up"],
"factory": "./upgrade/",
"factory": "./upgrade/index",
"schema": "./upgrade/schema.json",
"description": "Run an upgrade script."
},
"keys-manager": {
"aliases": ["km"],
"factory": "./keys-manager/",
"factory": "./keys-manager/index",
"schema": "./keys-manager/schema.json",
"description": "Add Transloco Keys Manager plugin to your project."
},
"join": {
"aliases": ["build"],
"factory": "./join/",
"factory": "./join/index",
"schema": "./join/schema.json",
"description": "Join the translation files into one."
},
"split": {
"aliases": ["sp"],
"factory": "./split/",
"factory": "./split/index",
"schema": "./split/schema.json",
"description": "split the translated files over the project's translation files."
},
"ng-migrate": {
"factory": "./ng-migrate/",
"factory": "./ng-migrate/index",
"schema": "./ng-migrate/schema.json",
"description": "split the translated files over the project's translation files."
}
Expand Down
2 changes: 1 addition & 1 deletion libs/transloco-schematics/src/join/schema.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "http://json-schema.org/schema",
"$id": "SchematicsTranslocoJoin",
"$id": "transloco-join",
"title": "Merge all of the project's translation files into one.",
"type": "object",
"properties": {
Expand Down
4 changes: 2 additions & 2 deletions libs/transloco-schematics/src/keys-manager/schema.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "http://json-schema.org/schema",
"$id": "SchematicsTranslocoKeysManager",
"title": "Add Transloco Keys Manager to your project",
"$id": "transloco-keys-manager",
"title": "Adds Transloco Keys Manager to a project",
"type": "object",
"properties": {
"strategy": {
Expand Down
2 changes: 1 addition & 1 deletion libs/transloco-schematics/src/migrate/schema.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "http://json-schema.org/schema",
"$id": "SchematicsTranslocoMigrate",
"$id": "transloco-migrate",
"title": "Run a migration script from @ngx-translate.",
"type": "object",
"properties": {
Expand Down
24 changes: 12 additions & 12 deletions libs/transloco-schematics/src/ng-add/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as _path from 'node:path';
import { dirname } from 'node:path';

import {
chain,
Expand All @@ -7,24 +7,24 @@ import {
SchematicContext,
Tree,
} from '@angular-devkit/schematics';

import { stringifyList } from '../utils/array';
import { getProject, setEnvironments } from '../utils/projects';
import { checkIfTranslationFilesExist } from '../utils/translations';
import { createConfig } from '../utils/transloco';
import {
getAppModulePath,
isStandaloneApp,
} from '../utils/ng-schematics-utils/ng-ast-utils';
} from '@schematics/angular/utility/ng-ast-utils';
import {
findBootstrapApplicationCall,
getMainFilePath,
} from '../utils/ng-schematics-utils/standalone/util';
} from '@schematics/angular/utility/standalone/util';
import {
addRootImport,
addRootProvider,
} from '../utils/ng-schematics-utils/standalone';
import { findAppConfig } from '../utils/ng-schematics-utils/standalone/app_config';
} from '@schematics/angular/utility/standalone/rules';
import { findAppConfig } from '@schematics/angular/utility/standalone/app_config';

import { stringifyList } from '../utils/array';
import { getProject, setEnvironments } from '../utils/projects';
import { checkIfTranslationFilesExist } from '../utils/translations';
import { createConfig } from '../utils/transloco';

import { Loaders, SchemaOptions } from './schema';
import { createLoaderFile } from './generators/http-loader.gen';
Expand Down Expand Up @@ -55,7 +55,7 @@ function resolveLoaderPath({ host, mainPath, isStandalone, modulePath }) {
const bootstrapCall = findBootstrapApplicationCall(host, mainPath);
resolved =
findAppConfig(bootstrapCall, host, mainPath)?.filePath || mainPath;
resolved = _path.dirname(resolved);
resolved = dirname(resolved);
}

return resolved;
Expand All @@ -75,7 +75,7 @@ export default function (options: SchemaOptions): Rule {
const isStandalone = isStandaloneApp(host, mainPath);
const modulePath = isStandalone
? ''
: _path.dirname(getAppModulePath(host, mainPath));
: dirname(getAppModulePath(host, mainPath));

const actions = [];

Expand Down
16 changes: 8 additions & 8 deletions libs/transloco-schematics/src/ng-add/schema.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "http://json-schema.org/schema",
"$id": "SchematicsTranslocoAdd",
"title": "Add Transloco to Your Project",
"$id": "transloco-ng-add",
"title": "Adds Transloco to a project",
"type": "object",
"properties": {
"langs": {
Expand All @@ -11,6 +11,12 @@
"default": "en, es",
"alias": "la"
},
"ssr": {
"description": "If the user is working with server side rendering.",
"x-prompt": "\uD83D\uDE80 Are you working with server side rendering?",
"type": "boolean",
"default": false
},
"loader": {
"description": "The loader strategy for the translate files.",
"type": "string",
Expand All @@ -25,12 +31,6 @@
"enum": ["JSON", "Typescript"],
"alias": "t"
},
"ssr": {
"description": "If the user is working with server side rendering.",
"x-prompt": "\uD83D\uDE80 Are you working with server side rendering?",
"type": "boolean",
"default": false
},
"path": {
"type": "string",
"default": "assets/i18n/",
Expand Down
2 changes: 1 addition & 1 deletion libs/transloco-schematics/src/ng-add/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface SchemaOptions {
*/
langs: string;
/**
* The languages of the project.
* The translations loader
*/
loader: Loaders;
/**
Expand Down
4 changes: 2 additions & 2 deletions libs/transloco-schematics/src/ng-migrate/schema.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "http://json-schema.org/schema",
"$id": "SchematicsTranslocoNgMigrate",
"title": "Migration Script from Angular",
"$id": "transloco-ng-migrate",
"title": "Run a migration script from Angular i18n",
"type": "object",
"properties": {
"langs": {
Expand Down
12 changes: 6 additions & 6 deletions libs/transloco-schematics/src/scope/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ import {
chain,
} from '@angular-devkit/schematics';
import { ScriptTarget, createSourceFile } from 'typescript';

import { LIB_NAME } from '../schematics.consts';
import { coerceArray, stringifyList } from '../utils/array';
import {
addProviderToModule,
insertImport,
addImportToModule,
} from '../utils/ng-schematics-utils/ast-utils';
} from '@schematics/angular/utility/ast-utils';
import { applyChangesToFile } from '@schematics/angular/utility/standalone/util';
import { Change } from '@schematics/angular/utility/change';

import { LIB_NAME } from '../schematics.consts';
import { coerceArray, stringifyList } from '../utils/array';
import { findModuleFromOptions } from '../utils/find-module';
import { getProject, getProjectPath } from '../utils/projects';
import { createTranslateFilesFromOptions } from '../utils/translations';
import { getConfig } from '../utils/config';
import { applyChangesToFile } from '../utils/ng-schematics-utils/standalone/util';
import { Change } from '../utils/ng-schematics-utils/change';

import { SchemaOptions } from './schema';

Expand Down
2 changes: 1 addition & 1 deletion libs/transloco-schematics/src/scope/schema.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "http://json-schema.org/schema",
"$id": "SchematicsTranslocoScope",
"$id": "transloco-scope",
"title": "Add new transloco scope module, along with translation files.",
"type": "object",
"properties": {
Expand Down
2 changes: 1 addition & 1 deletion libs/transloco-schematics/src/split/schema.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "http://json-schema.org/schema",
"$id": "SchematicsTranslocoSplit",
"$id": "transloco-split",
"title": "Split translated files between the project's translation files.",
"type": "object",
"properties": {
Expand Down
4 changes: 2 additions & 2 deletions libs/transloco-schematics/src/upgrade/schema.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "http://json-schema.org/schema",
"$id": "SchematicsTranslocoUpgrade",
"title": "Run an upgrade script.",
"$id": "transloco-upgrade",
"title": "Run an upgrade script [Legacy and will be removed in v7]",
"type": "object",
"properties": {
"path": {
Expand Down

This file was deleted.

Loading

0 comments on commit b69f61e

Please sign in to comment.