@jsverse/transloco-schematics 8.0.0
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 +34 -0
- package/schematics-core/index.d.ts +9 -0
- package/schematics-core/index.js +36 -0
- package/schematics-core/index.js.map +1 -0
- package/schematics-core/utils/collections.d.ts +3 -0
- package/schematics-core/utils/collections.js +11 -0
- package/schematics-core/utils/collections.js.map +1 -0
- package/schematics-core/utils/file.d.ts +6 -0
- package/schematics-core/utils/file.js +21 -0
- package/schematics-core/utils/file.js.map +1 -0
- package/schematics-core/utils/find-module.d.ts +23 -0
- package/schematics-core/utils/find-module.js +112 -0
- package/schematics-core/utils/find-module.js.map +1 -0
- package/schematics-core/utils/package.d.ts +2 -0
- package/schematics-core/utils/package.js +15 -0
- package/schematics-core/utils/package.js.map +1 -0
- package/schematics-core/utils/schematic.d.ts +6 -0
- package/schematics-core/utils/schematic.js +17 -0
- package/schematics-core/utils/schematic.js.map +1 -0
- package/schematics-core/utils/translation.d.ts +20 -0
- package/schematics-core/utils/translation.js +83 -0
- package/schematics-core/utils/translation.js.map +1 -0
- package/schematics-core/utils/transloco.d.ts +5 -0
- package/schematics-core/utils/transloco.js +31 -0
- package/schematics-core/utils/transloco.js.map +1 -0
- package/schematics-core/utils/workspace.d.ts +6 -0
- package/schematics-core/utils/workspace.js +43 -0
- package/schematics-core/utils/workspace.js.map +1 -0
- package/src/collection.json +41 -0
- package/src/join/index.d.ts +3 -0
- package/src/join/index.js +66 -0
- package/src/join/index.js.map +1 -0
- package/src/join/schema.d.ts +23 -0
- package/src/join/schema.js +3 -0
- package/src/join/schema.js.map +1 -0
- package/src/join/schema.json +36 -0
- package/src/keys-manager/index.d.ts +5 -0
- package/src/keys-manager/index.js +93 -0
- package/src/keys-manager/index.js.map +1 -0
- package/src/keys-manager/schema.d.ts +19 -0
- package/src/keys-manager/schema.js +3 -0
- package/src/keys-manager/schema.js.map +1 -0
- package/src/keys-manager/schema.json +33 -0
- package/src/ng-migrate/index.d.ts +3 -0
- package/src/ng-migrate/index.js +14 -0
- package/src/ng-migrate/index.js.map +1 -0
- package/src/ng-migrate/ng-migrate.d.ts +5 -0
- package/src/ng-migrate/ng-migrate.js +105 -0
- package/src/ng-migrate/ng-migrate.js.map +1 -0
- package/src/ng-migrate/schema.d.ts +14 -0
- package/src/ng-migrate/schema.js +3 -0
- package/src/ng-migrate/schema.js.map +1 -0
- package/src/ng-migrate/schema.json +27 -0
- package/src/ngx-migrate/index.d.ts +4 -0
- package/src/ngx-migrate/index.js +78 -0
- package/src/ngx-migrate/index.js.map +1 -0
- package/src/ngx-migrate/migration-matchers.d.ts +15 -0
- package/src/ngx-migrate/migration-matchers.js +132 -0
- package/src/ngx-migrate/migration-matchers.js.map +1 -0
- package/src/ngx-migrate/schema.d.ts +6 -0
- package/src/ngx-migrate/schema.js +3 -0
- package/src/ngx-migrate/schema.js.map +1 -0
- package/src/ngx-migrate/schema.json +16 -0
- package/src/scope/index.d.ts +3 -0
- package/src/scope/index.js +100 -0
- package/src/scope/index.js.map +1 -0
- package/src/scope/schema.d.ts +28 -0
- package/src/scope/schema.js +3 -0
- package/src/scope/schema.js.map +1 -0
- package/src/scope/schema.json +84 -0
- package/src/scope/utils.d.ts +4 -0
- package/src/scope/utils.js +14 -0
- package/src/scope/utils.js.map +1 -0
- package/src/split/index.d.ts +3 -0
- package/src/split/index.js +50 -0
- package/src/split/index.js.map +1 -0
- package/src/split/schema.d.ts +15 -0
- package/src/split/schema.js +3 -0
- package/src/split/schema.js.map +1 -0
- package/src/split/schema.json +28 -0
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@jsverse/transloco-schematics",
|
|
3
|
+
"version": "8.0.0",
|
|
4
|
+
"description": "Transloco's Angular schematics",
|
|
5
|
+
"schematics": "./src/collection.json",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"bugs": {
|
|
10
|
+
"url": "https://github.com/jsverse/transloco/issues"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://jsverse.gitbook.io/transloco/schematics",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "https://github.com/jsverse/transloco"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"Angular",
|
|
19
|
+
"i18n",
|
|
20
|
+
"Translate",
|
|
21
|
+
"Angular Translate",
|
|
22
|
+
"Transloco",
|
|
23
|
+
"Schematics",
|
|
24
|
+
"Angular CLI"
|
|
25
|
+
],
|
|
26
|
+
"license": "MIT",
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"glob": "^10.0.0",
|
|
29
|
+
"fs-extra": "^11.0.0"
|
|
30
|
+
},
|
|
31
|
+
"main": "./../../.js",
|
|
32
|
+
"type": "commonjs",
|
|
33
|
+
"types": "./../../.d.ts"
|
|
34
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { stringifyList, coerceArray } from './utils/collections';
|
|
2
|
+
export { addScriptToPackageJson } from './utils/package';
|
|
3
|
+
export { getProject, setEnvironments, getWorkspace, setWorkspace, } from './utils/workspace';
|
|
4
|
+
export { createGlobalConfig, getGlobalConfig, updateGlobalConfig, } from './utils/transloco';
|
|
5
|
+
export { createTranslateFiles, checkIfTranslationFilesExist, } from './utils/translation';
|
|
6
|
+
export { getTranslationEntryPaths, getTranslationFiles, getTranslationKey, getTranslationsRoot, createTranslateFilesFromOptions, } from './utils/translation';
|
|
7
|
+
export { hasFiles, hasSubdirs, getJsonFileContent, writeToJson, } from './utils/file';
|
|
8
|
+
export { NAMES } from './utils/schematic';
|
|
9
|
+
export { findModuleFromOptions } from './utils/find-module';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.findModuleFromOptions = exports.NAMES = exports.writeToJson = exports.getJsonFileContent = exports.hasSubdirs = exports.hasFiles = exports.createTranslateFilesFromOptions = exports.getTranslationsRoot = exports.getTranslationKey = exports.getTranslationFiles = exports.getTranslationEntryPaths = exports.checkIfTranslationFilesExist = exports.createTranslateFiles = exports.updateGlobalConfig = exports.getGlobalConfig = exports.createGlobalConfig = exports.setWorkspace = exports.getWorkspace = exports.setEnvironments = exports.getProject = exports.addScriptToPackageJson = exports.coerceArray = exports.stringifyList = void 0;
|
|
4
|
+
var collections_1 = require("./utils/collections");
|
|
5
|
+
Object.defineProperty(exports, "stringifyList", { enumerable: true, get: function () { return collections_1.stringifyList; } });
|
|
6
|
+
Object.defineProperty(exports, "coerceArray", { enumerable: true, get: function () { return collections_1.coerceArray; } });
|
|
7
|
+
var package_1 = require("./utils/package");
|
|
8
|
+
Object.defineProperty(exports, "addScriptToPackageJson", { enumerable: true, get: function () { return package_1.addScriptToPackageJson; } });
|
|
9
|
+
var workspace_1 = require("./utils/workspace");
|
|
10
|
+
Object.defineProperty(exports, "getProject", { enumerable: true, get: function () { return workspace_1.getProject; } });
|
|
11
|
+
Object.defineProperty(exports, "setEnvironments", { enumerable: true, get: function () { return workspace_1.setEnvironments; } });
|
|
12
|
+
Object.defineProperty(exports, "getWorkspace", { enumerable: true, get: function () { return workspace_1.getWorkspace; } });
|
|
13
|
+
Object.defineProperty(exports, "setWorkspace", { enumerable: true, get: function () { return workspace_1.setWorkspace; } });
|
|
14
|
+
var transloco_1 = require("./utils/transloco");
|
|
15
|
+
Object.defineProperty(exports, "createGlobalConfig", { enumerable: true, get: function () { return transloco_1.createGlobalConfig; } });
|
|
16
|
+
Object.defineProperty(exports, "getGlobalConfig", { enumerable: true, get: function () { return transloco_1.getGlobalConfig; } });
|
|
17
|
+
Object.defineProperty(exports, "updateGlobalConfig", { enumerable: true, get: function () { return transloco_1.updateGlobalConfig; } });
|
|
18
|
+
var translation_1 = require("./utils/translation");
|
|
19
|
+
Object.defineProperty(exports, "createTranslateFiles", { enumerable: true, get: function () { return translation_1.createTranslateFiles; } });
|
|
20
|
+
Object.defineProperty(exports, "checkIfTranslationFilesExist", { enumerable: true, get: function () { return translation_1.checkIfTranslationFilesExist; } });
|
|
21
|
+
var translation_2 = require("./utils/translation");
|
|
22
|
+
Object.defineProperty(exports, "getTranslationEntryPaths", { enumerable: true, get: function () { return translation_2.getTranslationEntryPaths; } });
|
|
23
|
+
Object.defineProperty(exports, "getTranslationFiles", { enumerable: true, get: function () { return translation_2.getTranslationFiles; } });
|
|
24
|
+
Object.defineProperty(exports, "getTranslationKey", { enumerable: true, get: function () { return translation_2.getTranslationKey; } });
|
|
25
|
+
Object.defineProperty(exports, "getTranslationsRoot", { enumerable: true, get: function () { return translation_2.getTranslationsRoot; } });
|
|
26
|
+
Object.defineProperty(exports, "createTranslateFilesFromOptions", { enumerable: true, get: function () { return translation_2.createTranslateFilesFromOptions; } });
|
|
27
|
+
var file_1 = require("./utils/file");
|
|
28
|
+
Object.defineProperty(exports, "hasFiles", { enumerable: true, get: function () { return file_1.hasFiles; } });
|
|
29
|
+
Object.defineProperty(exports, "hasSubdirs", { enumerable: true, get: function () { return file_1.hasSubdirs; } });
|
|
30
|
+
Object.defineProperty(exports, "getJsonFileContent", { enumerable: true, get: function () { return file_1.getJsonFileContent; } });
|
|
31
|
+
Object.defineProperty(exports, "writeToJson", { enumerable: true, get: function () { return file_1.writeToJson; } });
|
|
32
|
+
var schematic_1 = require("./utils/schematic");
|
|
33
|
+
Object.defineProperty(exports, "NAMES", { enumerable: true, get: function () { return schematic_1.NAMES; } });
|
|
34
|
+
var find_module_1 = require("./utils/find-module");
|
|
35
|
+
Object.defineProperty(exports, "findModuleFromOptions", { enumerable: true, get: function () { return find_module_1.findModuleFromOptions; } });
|
|
36
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/transloco-schematics/schematics-core/index.ts"],"names":[],"mappings":";;;AAAA,mDAAiE;AAAxD,4GAAA,aAAa,OAAA;AAAE,0GAAA,WAAW,OAAA;AACnC,2CAAyD;AAAhD,iHAAA,sBAAsB,OAAA;AAC/B,+CAK2B;AAJzB,uGAAA,UAAU,OAAA;AACV,4GAAA,eAAe,OAAA;AACf,yGAAA,YAAY,OAAA;AACZ,yGAAA,YAAY,OAAA;AAEd,+CAI2B;AAHzB,+GAAA,kBAAkB,OAAA;AAClB,4GAAA,eAAe,OAAA;AACf,+GAAA,kBAAkB,OAAA;AAEpB,mDAG6B;AAF3B,mHAAA,oBAAoB,OAAA;AACpB,2HAAA,4BAA4B,OAAA;AAG9B,mDAM6B;AAL3B,uHAAA,wBAAwB,OAAA;AACxB,kHAAA,mBAAmB,OAAA;AACnB,gHAAA,iBAAiB,OAAA;AACjB,kHAAA,mBAAmB,OAAA;AACnB,8HAAA,+BAA+B,OAAA;AAEjC,qCAKsB;AAJpB,gGAAA,QAAQ,OAAA;AACR,kGAAA,UAAU,OAAA;AACV,0GAAA,kBAAkB,OAAA;AAClB,mGAAA,WAAW,OAAA;AAEb,+CAA0C;AAAjC,kGAAA,KAAK,OAAA;AACd,mDAA4D;AAAnD,oHAAA,qBAAqB,OAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.stringifyList = stringifyList;
|
|
4
|
+
exports.coerceArray = coerceArray;
|
|
5
|
+
function stringifyList(list, separator = ', ') {
|
|
6
|
+
return list.map((item) => `'${item}'`).join(separator);
|
|
7
|
+
}
|
|
8
|
+
function coerceArray(value) {
|
|
9
|
+
return Array.isArray(value) ? value : [value];
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=collections.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collections.js","sourceRoot":"","sources":["../../../../../libs/transloco-schematics/schematics-core/utils/collections.ts"],"names":[],"mappings":";;AAAA,sCAEC;AAID,kCAEC;AARD,SAAgB,aAAa,CAAI,IAAS,EAAE,SAAS,GAAG,IAAI;IAC1D,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AACzD,CAAC;AAID,SAAgB,WAAW,CAAI,KAAc;IAC3C,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AAChD,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { PathFragment } from '@angular-devkit/core';
|
|
2
|
+
import { DirEntry, Tree } from '@angular-devkit/schematics';
|
|
3
|
+
export declare function getJsonFileContent(fileName: PathFragment, dir: DirEntry): any;
|
|
4
|
+
export declare function writeToJson(host: Tree, dirPath: string, fileName: PathFragment, content: unknown): void;
|
|
5
|
+
export declare function hasSubdirs(dir: DirEntry): boolean;
|
|
6
|
+
export declare function hasFiles(dir: DirEntry): boolean;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getJsonFileContent = getJsonFileContent;
|
|
4
|
+
exports.writeToJson = writeToJson;
|
|
5
|
+
exports.hasSubdirs = hasSubdirs;
|
|
6
|
+
exports.hasFiles = hasFiles;
|
|
7
|
+
const nodePath = require("node:path");
|
|
8
|
+
function getJsonFileContent(fileName, dir) {
|
|
9
|
+
const content = dir.file(fileName).content.toString('utf-8');
|
|
10
|
+
return JSON.parse(content);
|
|
11
|
+
}
|
|
12
|
+
function writeToJson(host, dirPath, fileName, content) {
|
|
13
|
+
return host.overwrite(nodePath.join(dirPath, fileName), JSON.stringify(content, null, 2));
|
|
14
|
+
}
|
|
15
|
+
function hasSubdirs(dir) {
|
|
16
|
+
return dir.subdirs && dir.subdirs.length > 0;
|
|
17
|
+
}
|
|
18
|
+
function hasFiles(dir) {
|
|
19
|
+
return dir.subfiles && dir.subfiles.length > 0;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file.js","sourceRoot":"","sources":["../../../../../libs/transloco-schematics/schematics-core/utils/file.ts"],"names":[],"mappings":";;AAKA,gDAIC;AAED,kCAUC;AAED,gCAEC;AAED,4BAEC;AA7BD,sCAAsC;AAKtC,SAAgB,kBAAkB,CAAC,QAAsB,EAAE,GAAa;IACtE,MAAM,OAAO,GAAG,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAE9D,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AAC7B,CAAC;AAED,SAAgB,WAAW,CACzB,IAAU,EACV,OAAe,EACf,QAAsB,EACtB,OAAgB;IAEhB,OAAO,IAAI,CAAC,SAAS,CACnB,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,EAChC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CACjC,CAAC;AACJ,CAAC;AAED,SAAgB,UAAU,CAAC,GAAa;IACtC,OAAO,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;AAC/C,CAAC;AAED,SAAgB,QAAQ,CAAC,GAAa;IACpC,OAAO,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;AACjD,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google Inc. All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
8
|
+
import { Path } from '@angular-devkit/core';
|
|
9
|
+
import { Tree } from '@angular-devkit/schematics';
|
|
10
|
+
export declare const MODULE_EXT = ".module.ts";
|
|
11
|
+
export declare const ROUTING_MODULE_EXT = "-routing.module.ts";
|
|
12
|
+
/**
|
|
13
|
+
* Find the module referred by a set of options passed to the schematics.
|
|
14
|
+
*/
|
|
15
|
+
export declare function findRootModule(host: Tree, module: string, rootPath?: string, skipImport?: boolean): string | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Find the module referred by a set of options passed to the schematics.
|
|
18
|
+
*/
|
|
19
|
+
export declare function findModuleFromOptions(host: Tree, options: any, projectPath: any): Path | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Function to find the "closest" module to a generated file's path.
|
|
22
|
+
*/
|
|
23
|
+
export declare function findModule(host: Tree, generateDir: string, moduleExt?: string, routingModuleExt?: string): Path;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ROUTING_MODULE_EXT = exports.MODULE_EXT = void 0;
|
|
4
|
+
exports.findRootModule = findRootModule;
|
|
5
|
+
exports.findModuleFromOptions = findModuleFromOptions;
|
|
6
|
+
exports.findModule = findModule;
|
|
7
|
+
/* eslint-disable */
|
|
8
|
+
// @ts-nocheck
|
|
9
|
+
/**
|
|
10
|
+
* @license
|
|
11
|
+
* Copyright Google Inc. All Rights Reserved.
|
|
12
|
+
*
|
|
13
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
14
|
+
* found in the LICENSE file at https://angular.io/license
|
|
15
|
+
*/
|
|
16
|
+
const core_1 = require("@angular-devkit/core");
|
|
17
|
+
exports.MODULE_EXT = '.module.ts';
|
|
18
|
+
exports.ROUTING_MODULE_EXT = '-routing.module.ts';
|
|
19
|
+
/**
|
|
20
|
+
* Find the module referred by a set of options passed to the schematics.
|
|
21
|
+
*/
|
|
22
|
+
function findRootModule(host, module, rootPath = '', skipImport = false) {
|
|
23
|
+
if (skipImport || !module) {
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
const modulePath = (0, core_1.normalize)(`${rootPath}/${module}`);
|
|
27
|
+
const matchingExt = [
|
|
28
|
+
'',
|
|
29
|
+
'.ts',
|
|
30
|
+
exports.MODULE_EXT,
|
|
31
|
+
`/${module}${exports.MODULE_EXT}`,
|
|
32
|
+
`/${module}.ts`,
|
|
33
|
+
].find((ext) => host.exists(modulePath + ext));
|
|
34
|
+
if (matchingExt) {
|
|
35
|
+
return (0, core_1.normalize)(modulePath + matchingExt);
|
|
36
|
+
}
|
|
37
|
+
throw new Error(`Specified module path ${modulePath} does not exist`);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Find the module referred by a set of options passed to the schematics.
|
|
41
|
+
*/
|
|
42
|
+
function findModuleFromOptions(host, options, projectPath) {
|
|
43
|
+
if (Object.prototype.hasOwnProperty.call(options, 'skipImport') &&
|
|
44
|
+
options.skipImport) {
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
const moduleExt = options.moduleExt || exports.MODULE_EXT;
|
|
48
|
+
const routingModuleExt = options.routingModuleExt || exports.ROUTING_MODULE_EXT;
|
|
49
|
+
if (!options.module) {
|
|
50
|
+
const pathToCheck = (projectPath || '') + '/' + options.name;
|
|
51
|
+
const module = findModule(host, pathToCheck, moduleExt, routingModuleExt);
|
|
52
|
+
return module ? (0, core_1.normalize)(module) : null;
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
const modulePath = (0, core_1.normalize)(`/${projectPath}/${options.module}`);
|
|
56
|
+
const componentPath = (0, core_1.normalize)(`/${projectPath}/${options.name}`);
|
|
57
|
+
const moduleBaseName = (0, core_1.normalize)(modulePath).split('/').pop();
|
|
58
|
+
const candidateSet = new Set([(0, core_1.normalize)(projectPath || '/')]);
|
|
59
|
+
for (let dir = modulePath; dir != core_1.NormalizedRoot; dir = (0, core_1.dirname)(dir)) {
|
|
60
|
+
candidateSet.add(dir);
|
|
61
|
+
}
|
|
62
|
+
for (let dir = componentPath; dir != core_1.NormalizedRoot; dir = (0, core_1.dirname)(dir)) {
|
|
63
|
+
candidateSet.add(dir);
|
|
64
|
+
}
|
|
65
|
+
const candidatesDirs = [...candidateSet].sort((a, b) => b.length - a.length);
|
|
66
|
+
for (const c of candidatesDirs) {
|
|
67
|
+
const candidateFiles = [
|
|
68
|
+
'',
|
|
69
|
+
`${moduleBaseName}.ts`,
|
|
70
|
+
`${moduleBaseName}${moduleExt}`,
|
|
71
|
+
].map((x) => (0, core_1.join)(c, x));
|
|
72
|
+
for (const sc of candidateFiles) {
|
|
73
|
+
if (host.exists(sc)) {
|
|
74
|
+
return (0, core_1.normalize)(sc);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return null;
|
|
79
|
+
throw new Error(`Specified module '${options.module}' does not exist.\n` +
|
|
80
|
+
`Looked in the following directories:\n ${candidatesDirs.join('\n ')}`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Function to find the "closest" module to a generated file's path.
|
|
85
|
+
*/
|
|
86
|
+
function findModule(host, generateDir, moduleExt = exports.MODULE_EXT, routingModuleExt = exports.ROUTING_MODULE_EXT) {
|
|
87
|
+
let dir = host.getDir('/' + generateDir);
|
|
88
|
+
let foundRoutingModule = false;
|
|
89
|
+
while (dir) {
|
|
90
|
+
const allMatches = dir.subfiles.filter((p) => p.endsWith(moduleExt));
|
|
91
|
+
const filteredMatches = allMatches.filter((p) => !p.endsWith(routingModuleExt));
|
|
92
|
+
foundRoutingModule =
|
|
93
|
+
foundRoutingModule || allMatches.length !== filteredMatches.length;
|
|
94
|
+
if (filteredMatches.length == 1) {
|
|
95
|
+
return (0, core_1.join)(dir.path, filteredMatches[0]);
|
|
96
|
+
}
|
|
97
|
+
else if (filteredMatches.length > 1) {
|
|
98
|
+
return null;
|
|
99
|
+
throw new Error('More than one module matches. Use skip-import option to skip importing ' +
|
|
100
|
+
'the component into the closest module.');
|
|
101
|
+
}
|
|
102
|
+
dir = dir.parent;
|
|
103
|
+
}
|
|
104
|
+
const errorMsg = foundRoutingModule
|
|
105
|
+
? 'Could not find a non Routing NgModule.' +
|
|
106
|
+
`\nModules with suffix '${routingModuleExt}' are strictly reserved for routing.` +
|
|
107
|
+
'\nUse the skip-import option to skip importing in NgModule.'
|
|
108
|
+
: 'Could not find an NgModule. Use the skip-import option to skip importing in NgModule.';
|
|
109
|
+
return null;
|
|
110
|
+
throw new Error(errorMsg);
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=find-module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find-module.js","sourceRoot":"","sources":["../../../../../libs/transloco-schematics/schematics-core/utils/find-module.ts"],"names":[],"mappings":";;;AAwBA,wCAwBC;AAKD,sDAyDC;AAKD,gCAsCC;AAzJD,oBAAoB;AACpB,cAAc;AACd;;;;;;GAMG;AACH,+CAM8B;AAGjB,QAAA,UAAU,GAAG,YAAY,CAAC;AAC1B,QAAA,kBAAkB,GAAG,oBAAoB,CAAC;AAEvD;;GAEG;AACH,SAAgB,cAAc,CAC5B,IAAU,EACV,MAAc,EACd,QAAQ,GAAG,EAAE,EACb,UAAU,GAAG,KAAK;IAElB,IAAI,UAAU,IAAI,CAAC,MAAM,EAAE,CAAC;QAC1B,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,UAAU,GAAG,IAAA,gBAAS,EAAC,GAAG,QAAQ,IAAI,MAAM,EAAE,CAAC,CAAC;IACtD,MAAM,WAAW,GAAG;QAClB,EAAE;QACF,KAAK;QACL,kBAAU;QACV,IAAI,MAAM,GAAG,kBAAU,EAAE;QACzB,IAAI,MAAM,KAAK;KAChB,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,GAAG,GAAG,CAAC,CAAC,CAAC;IAE/C,IAAI,WAAW,EAAE,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|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addScriptToPackageJson = addScriptToPackageJson;
|
|
4
|
+
function addScriptToPackageJson(host, scriptName, script) {
|
|
5
|
+
const packageFile = host.read('package.json');
|
|
6
|
+
if (packageFile !== null) {
|
|
7
|
+
const sourceText = packageFile.toString('utf-8');
|
|
8
|
+
const json = JSON.parse(sourceText);
|
|
9
|
+
json['scripts'] ??= {};
|
|
10
|
+
json['scripts'][scriptName] = script;
|
|
11
|
+
host.overwrite('package.json', JSON.stringify(json, null, 2));
|
|
12
|
+
}
|
|
13
|
+
return host;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=package.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package.js","sourceRoot":"","sources":["../../../../../libs/transloco-schematics/schematics-core/utils/package.ts"],"names":[],"mappings":";;AAEA,wDAgBC;AAhBD,SAAgB,sBAAsB,CACpC,IAAU,EACV,UAAkB,EAClB,MAAc;IAEd,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IAC9C,IAAI,WAAW,KAAK,IAAI,EAAE,CAAC;QACzB,MAAM,UAAU,GAAG,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QACjD,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QACpC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;QACvB,IAAI,CAAC,SAAS,CAAC,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC;QAErC,IAAI,CAAC,SAAS,CAAC,cAAc,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAChE,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NAMES = void 0;
|
|
4
|
+
exports.generateConfigFile = generateConfigFile;
|
|
5
|
+
const node_util_1 = require("node:util");
|
|
6
|
+
exports.NAMES = {
|
|
7
|
+
LIB_NAME: '@jsverse/transloco',
|
|
8
|
+
CONFIG_FILE: 'transloco.config.ts',
|
|
9
|
+
};
|
|
10
|
+
function generateConfigFile(config) {
|
|
11
|
+
return `import {TranslocoGlobalConfig} from '@jsverse/transloco-utils';
|
|
12
|
+
|
|
13
|
+
const config: TranslocoGlobalConfig = ${(0, node_util_1.inspect)(config)};
|
|
14
|
+
|
|
15
|
+
export default config;`;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=schematic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schematic.js","sourceRoot":"","sources":["../../../../../libs/transloco-schematics/schematics-core/utils/schematic.ts"],"names":[],"mappings":";;;AASA,gDAMC;AAfD,yCAAoC;AAIvB,QAAA,KAAK,GAAG;IACnB,QAAQ,EAAE,oBAAoB;IAC9B,WAAW,EAAE,qBAAqB;CACnC,CAAC;AAEF,SAAgB,kBAAkB,CAAC,MAA6B;IAC9D,OAAO;;wCAE+B,IAAA,mBAAO,EAAC,MAAM,CAAC;;uBAEhC,CAAC;AACxB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Tree } from '@angular-devkit/schematics';
|
|
2
|
+
export declare function createTranslateFiles(langs: string[], path: string): import("@angular-devkit/schematics").Source;
|
|
3
|
+
export declare function checkIfTranslationFilesExist(path: string, langs: string[], extension: string, skipThrow?: boolean): boolean;
|
|
4
|
+
export declare function createTranslateFilesFromOptions(host: Tree, options: {
|
|
5
|
+
langs: string[];
|
|
6
|
+
translationFilePath: string;
|
|
7
|
+
}): import("@angular-devkit/schematics").Source;
|
|
8
|
+
export declare function getTranslationKey(prefix: string, key: string): string;
|
|
9
|
+
export declare function getTranslationsRoot(host: Tree, options: {
|
|
10
|
+
project?: string;
|
|
11
|
+
translationPath?: string;
|
|
12
|
+
}): string;
|
|
13
|
+
export declare function getTranslationFiles(host: Tree, root: string): {
|
|
14
|
+
lang: string;
|
|
15
|
+
translation: Record<string, unknown>;
|
|
16
|
+
}[];
|
|
17
|
+
export declare function getTranslationEntryPaths(host: Tree, rootDirPath: string): {
|
|
18
|
+
scope: string;
|
|
19
|
+
path: string;
|
|
20
|
+
}[];
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createTranslateFiles = createTranslateFiles;
|
|
4
|
+
exports.checkIfTranslationFilesExist = checkIfTranslationFilesExist;
|
|
5
|
+
exports.createTranslateFilesFromOptions = createTranslateFilesFromOptions;
|
|
6
|
+
exports.getTranslationKey = getTranslationKey;
|
|
7
|
+
exports.getTranslationsRoot = getTranslationsRoot;
|
|
8
|
+
exports.getTranslationFiles = getTranslationFiles;
|
|
9
|
+
exports.getTranslationEntryPaths = getTranslationEntryPaths;
|
|
10
|
+
const nodePath = require("node:path");
|
|
11
|
+
const fs = require("node:fs");
|
|
12
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
13
|
+
const workspace_1 = require("./workspace");
|
|
14
|
+
const file_1 = require("./file");
|
|
15
|
+
const transloco_1 = require("./transloco");
|
|
16
|
+
function jsonTranslationFileCreator(source, lang) {
|
|
17
|
+
source.create(`${lang}.json`, `{}
|
|
18
|
+
`);
|
|
19
|
+
}
|
|
20
|
+
function createTranslateFiles(langs, path) {
|
|
21
|
+
const treeSource = new schematics_1.EmptyTree();
|
|
22
|
+
for (const lang of langs) {
|
|
23
|
+
jsonTranslationFileCreator(treeSource, lang);
|
|
24
|
+
}
|
|
25
|
+
return (0, schematics_1.apply)((0, schematics_1.source)(treeSource), [(0, schematics_1.move)('/', path)]);
|
|
26
|
+
}
|
|
27
|
+
function checkIfTranslationFilesExist(path, langs, extension, skipThrow) {
|
|
28
|
+
for (const lang of langs) {
|
|
29
|
+
const filePath = nodePath.resolve(`${path}/${lang}${extension}`);
|
|
30
|
+
if (fs.existsSync(filePath)) {
|
|
31
|
+
if (skipThrow) {
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
throw new schematics_1.SchematicsException(`Translation file ${filePath} is already exist, please use --skip-creation`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
function createTranslateFilesFromOptions(host, options) {
|
|
40
|
+
const extension = '.json';
|
|
41
|
+
checkIfTranslationFilesExist(options.translationFilePath, options.langs, extension);
|
|
42
|
+
return createTranslateFiles(options.langs, options.translationFilePath);
|
|
43
|
+
}
|
|
44
|
+
function getTranslationKey(prefix = '', key) {
|
|
45
|
+
return prefix ? `${prefix}.${key}` : key;
|
|
46
|
+
}
|
|
47
|
+
function getTranslationsRoot(host, options) {
|
|
48
|
+
const translocoConfig = (0, transloco_1.getGlobalConfig)();
|
|
49
|
+
if (options.translationPath) {
|
|
50
|
+
return options.translationPath;
|
|
51
|
+
}
|
|
52
|
+
else if (translocoConfig && translocoConfig.rootTranslationsPath) {
|
|
53
|
+
return translocoConfig.rootTranslationsPath;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
const project = (0, workspace_1.getProject)(host, options.project || '');
|
|
57
|
+
const rootPath = (project && project.sourceRoot) || 'src';
|
|
58
|
+
return nodePath.join(rootPath, 'assets', 'i18n');
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function getTranslationFiles(host, root) {
|
|
62
|
+
const rootDir = host.getDir(root);
|
|
63
|
+
return rootDir.subfiles.map((fileName) => ({
|
|
64
|
+
lang: fileName.split('.')[0],
|
|
65
|
+
translation: (0, file_1.getJsonFileContent)(fileName, rootDir),
|
|
66
|
+
}));
|
|
67
|
+
}
|
|
68
|
+
function getTranslationEntryPaths(host, rootDirPath) {
|
|
69
|
+
const translocoConfig = (0, transloco_1.getGlobalConfig)();
|
|
70
|
+
if (translocoConfig.scopePathMap &&
|
|
71
|
+
Object.keys(translocoConfig.scopePathMap).length) {
|
|
72
|
+
return Object.entries(translocoConfig.scopePathMap).map(([scope, path]) => ({
|
|
73
|
+
scope,
|
|
74
|
+
path: path,
|
|
75
|
+
}));
|
|
76
|
+
}
|
|
77
|
+
const rootDir = host.getDir(rootDirPath);
|
|
78
|
+
return rootDir.subdirs.map((subDir) => ({
|
|
79
|
+
scope: subDir,
|
|
80
|
+
path: nodePath.join(rootDirPath, subDir),
|
|
81
|
+
}));
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=translation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"translation.js","sourceRoot":"","sources":["../../../../../libs/transloco-schematics/schematics-core/utils/translation.ts"],"names":[],"mappings":";;AAwBA,oDAOC;AAED,oEAkBC;AAED,0EAaC;AAED,8CAEC;AAED,kDAcC;AAED,kDASC;AAED,4DAuBC;AA1HD,sCAAsC;AACtC,8BAA8B;AAE9B,2DAOoC;AAEpC,2CAAyC;AACzC,iCAA4C;AAC5C,2CAA8C;AAE9C,SAAS,0BAA0B,CAAC,MAAY,EAAE,IAAY;IAC5D,MAAM,CAAC,MAAM,CACX,GAAG,IAAI,OAAO,EACd;CACH,CACE,CAAC;AACJ,CAAC;AAED,SAAgB,oBAAoB,CAAC,KAAe,EAAE,IAAY;IAChE,MAAM,UAAU,GAAG,IAAI,sBAAS,EAAE,CAAC;IACnC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,0BAA0B,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;IAC/C,CAAC;IAED,OAAO,IAAA,kBAAK,EAAC,IAAA,mBAAM,EAAC,UAAU,CAAC,EAAE,CAAC,IAAA,iBAAI,EAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;AACtD,CAAC;AAED,SAAgB,4BAA4B,CAC1C,IAAY,EACZ,KAAe,EACf,SAAiB,EACjB,SAAmB;IAEnB,KAAK,MAA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AAC;AACN,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Tree } from '@angular-devkit/schematics';
|
|
2
|
+
import { TranslocoGlobalConfig } from '@jsverse/transloco-utils';
|
|
3
|
+
export declare function getGlobalConfig(): TranslocoGlobalConfig;
|
|
4
|
+
export declare function createGlobalConfig(host: Tree, langs: string[], rootTranslationsPath?: string): void;
|
|
5
|
+
export declare function updateGlobalConfig(host: Tree, config: TranslocoGlobalConfig): void;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getGlobalConfig = getGlobalConfig;
|
|
4
|
+
exports.createGlobalConfig = createGlobalConfig;
|
|
5
|
+
exports.updateGlobalConfig = updateGlobalConfig;
|
|
6
|
+
const transloco_utils_1 = require("@jsverse/transloco-utils");
|
|
7
|
+
const schematic_1 = require("./schematic");
|
|
8
|
+
let config;
|
|
9
|
+
function getGlobalConfig() {
|
|
10
|
+
if (config)
|
|
11
|
+
return config;
|
|
12
|
+
config = (0, transloco_utils_1.getGlobalConfig)();
|
|
13
|
+
return config;
|
|
14
|
+
}
|
|
15
|
+
function createGlobalConfig(host, langs, rootTranslationsPath = 'assets/i18n/') {
|
|
16
|
+
if (!host.get(schematic_1.NAMES.CONFIG_FILE)) {
|
|
17
|
+
host.create(schematic_1.NAMES.CONFIG_FILE, (0, schematic_1.generateConfigFile)({
|
|
18
|
+
rootTranslationsPath: rootTranslationsPath,
|
|
19
|
+
langs,
|
|
20
|
+
keysManager: {},
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function updateGlobalConfig(host, config) {
|
|
25
|
+
const originalConfig = getGlobalConfig();
|
|
26
|
+
if (!originalConfig || Object.keys(originalConfig).length === 0) {
|
|
27
|
+
return createGlobalConfig(host, config.langs || [], config.rootTranslationsPath);
|
|
28
|
+
}
|
|
29
|
+
host.overwrite(schematic_1.NAMES.CONFIG_FILE, (0, schematic_1.generateConfigFile)({ ...config, ...originalConfig }));
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=transloco.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transloco.js","sourceRoot":"","sources":["../../../../../libs/transloco-schematics/schematics-core/utils/transloco.ts"],"names":[],"mappings":";;AAUA,0CAKC;AAED,gDAeC;AAED,gDAaC;AA9CD,8DAGkC;AAElC,2CAAwD;AAExD,IAAI,MAA6B,CAAC;AAElC,SAAgB,eAAe;IAC7B,IAAI,MAAM;QAAE,OAAO,MAAM,CAAC;IAC1B,MAAM,GAAG,IAAA,iCAAgB,GAAE,CAAC;IAE5B,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAgB,kBAAkB,CAChC,IAAU,EACV,KAAe,EACf,oBAAoB,GAAG,cAAc;IAErC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,iBAAK,CAAC,WAAW,CAAC,EAAE,CAAC;QACjC,IAAI,CAAC,MAAM,CACT,iBAAK,CAAC,WAAW,EACjB,IAAA,8BAAkB,EAAC;YACjB,oBAAoB,EAAE,oBAAoB;YAC1C,KAAK;YACL,WAAW,EAAE,EAAE;SAChB,CAAC,CACH,CAAC;IACJ,CAAC;AACH,CAAC;AAED,SAAgB,kBAAkB,CAAC,IAAU,EAAE,MAA6B;IAC1E,MAAM,cAAc,GAAG,eAAe,EAAE,CAAC;IACzC,IAAI,CAAC,cAAc,IAAI,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAChE,OAAO,kBAAkB,CACvB,IAAI,EACJ,MAAM,CAAC,KAAK,IAAI,EAAE,EAClB,MAAM,CAAC,oBAAoB,CAC5B,CAAC;IACJ,CAAC;IACD,IAAI,CAAC,SAAS,CACZ,iBAAK,CAAC,WAAW,EACjB,IAAA,8BAAkB,EAAC,EAAE,GAAG,MAAM,EAAE,GAAG,cAAc,EAAE,CAAC,CACrD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { WorkspaceSchema } from '@schematics/angular/utility/workspace-models';
|
|
2
|
+
import { Tree } from '@angular-devkit/schematics';
|
|
3
|
+
export declare function getWorkspace(host: Tree): WorkspaceSchema;
|
|
4
|
+
export declare function setWorkspace(host: Tree, workspace: WorkspaceSchema): void;
|
|
5
|
+
export declare function getProject(host: Tree, project: string): import("@schematics/angular/utility/workspace-models").WorkspaceProject<import("@schematics/angular/utility/workspace-models").ProjectType>;
|
|
6
|
+
export declare function setEnvironments(host: Tree, sourceRoot: string, transformer: (env: string) => string): void;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getWorkspace = getWorkspace;
|
|
4
|
+
exports.setWorkspace = setWorkspace;
|
|
5
|
+
exports.getProject = getProject;
|
|
6
|
+
exports.setEnvironments = setEnvironments;
|
|
7
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
8
|
+
function getWorkspacePath(host) {
|
|
9
|
+
const possibleFiles = ['/angular.json', '/.angular.json'];
|
|
10
|
+
const [path] = possibleFiles.filter((path) => host.exists(path));
|
|
11
|
+
return path;
|
|
12
|
+
}
|
|
13
|
+
function getWorkspace(host) {
|
|
14
|
+
const path = getWorkspacePath(host);
|
|
15
|
+
const configBuffer = host.read(path);
|
|
16
|
+
if (configBuffer === null) {
|
|
17
|
+
throw new schematics_1.SchematicsException(`Could not find (${path})`);
|
|
18
|
+
}
|
|
19
|
+
const config = configBuffer.toString();
|
|
20
|
+
return JSON.parse(config);
|
|
21
|
+
}
|
|
22
|
+
function setWorkspace(host, workspace) {
|
|
23
|
+
const path = getWorkspacePath(host);
|
|
24
|
+
host.overwrite(path, JSON.stringify(workspace, null, 2));
|
|
25
|
+
}
|
|
26
|
+
function getProject(host, project) {
|
|
27
|
+
const workspace = getWorkspace(host);
|
|
28
|
+
if (workspace) {
|
|
29
|
+
return workspace.projects[project];
|
|
30
|
+
}
|
|
31
|
+
throw new schematics_1.SchematicsException('could not find a workspace project');
|
|
32
|
+
}
|
|
33
|
+
function setEnvironments(host, sourceRoot, transformer) {
|
|
34
|
+
const path = sourceRoot + '/environments';
|
|
35
|
+
const environments = host.getDir(path);
|
|
36
|
+
return environments.subfiles.forEach((file) => {
|
|
37
|
+
const filePath = `${path}/${file}`;
|
|
38
|
+
const configBuffer = host.read(filePath);
|
|
39
|
+
const source = configBuffer.toString('utf-8');
|
|
40
|
+
host.overwrite(filePath, transformer(source));
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=workspace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace.js","sourceRoot":"","sources":["../../../../../libs/transloco-schematics/schematics-core/utils/workspace.ts"],"names":[],"mappings":";;AAUA,oCASC;AAED,oCAIC;AAED,gCAOC;AAED,0CAcC;AAjDD,2DAAuE;AAEvE,SAAS,gBAAgB,CAAC,IAAU;IAClC,MAAM,aAAa,GAAG,CAAC,eAAe,EAAE,gBAAgB,CAAC,CAAC;IAC1D,MAAM,CAAC,IAAI,CAAC,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;IAEjE,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAgB,YAAY,CAAC,IAAU;IACrC,MAAM,IAAI,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACpC,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACrC,IAAI,YAAY,KAAK,IAAI,EAAE,CAAC;QAC1B,MAAM,IAAI,gCAAmB,CAAC,mBAAmB,IAAI,GAAG,CAAC,CAAC;IAC5D,CAAC;IACD,MAAM,MAAM,GAAG,YAAY,CAAC,QAAQ,EAAE,CAAC;IAEvC,OAAO,IAA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
|
+
"schematics": {
|
|
5
|
+
"ng-migrate": {
|
|
6
|
+
"factory": "./ng-migrate/index",
|
|
7
|
+
"schema": "./ng-migrate/schema.json",
|
|
8
|
+
"description": "Migrate from Angular i18n to Transloco."
|
|
9
|
+
},
|
|
10
|
+
"ngx-migrate": {
|
|
11
|
+
"aliases": ["m"],
|
|
12
|
+
"factory": "./ngx-migrate/index",
|
|
13
|
+
"schema": "./ngx-migrate/schema.json",
|
|
14
|
+
"description": "Migrate from @ngx-translate to Transloco."
|
|
15
|
+
},
|
|
16
|
+
"scope": {
|
|
17
|
+
"aliases": ["s"],
|
|
18
|
+
"factory": "./scope/index",
|
|
19
|
+
"schema": "./scope/schema.json",
|
|
20
|
+
"description": "Add transloco scope."
|
|
21
|
+
},
|
|
22
|
+
"keys-manager": {
|
|
23
|
+
"aliases": ["km"],
|
|
24
|
+
"factory": "./keys-manager/index",
|
|
25
|
+
"schema": "./keys-manager/schema.json",
|
|
26
|
+
"description": "Add TKM (Transloco Keys Manager) plugin to your project."
|
|
27
|
+
},
|
|
28
|
+
"join": {
|
|
29
|
+
"aliases": ["build"],
|
|
30
|
+
"factory": "./join/index",
|
|
31
|
+
"schema": "./join/schema.json",
|
|
32
|
+
"description": "Join the translation files into one."
|
|
33
|
+
},
|
|
34
|
+
"split": {
|
|
35
|
+
"aliases": ["sp"],
|
|
36
|
+
"factory": "./split/index",
|
|
37
|
+
"schema": "./split/schema.json",
|
|
38
|
+
"description": "split the translated files over the project's translation files."
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|