@rxap/plugin-angular 20.0.1-dev.11 → 20.0.1-dev.13

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.
Files changed (80) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/package.json +16 -3
  3. package/.eslintignore +0 -6
  4. package/.eslintrc.json +0 -44
  5. package/LICENSE +0 -621
  6. package/README.md.handlebars +0 -115
  7. package/jest.config.ts +0 -11
  8. package/project.json +0 -68
  9. package/schematics.yaml +0 -6
  10. package/src/application.ts +0 -124
  11. package/src/executors/check-ng-package/executor.ts +0 -33
  12. package/src/executors/config/executor.ts +0 -74
  13. package/src/executors/i18n/executor.ts +0 -198
  14. package/src/executors/tailwind/executor.ts +0 -34
  15. package/src/generators/convert-to-buildable-library/generator.ts +0 -110
  16. package/src/generators/fix-schematic/generator.ts +0 -103
  17. package/src/generators/fix-schematic/index.ts +0 -5
  18. package/src/generators/init/coerce-nx-json.ts +0 -72
  19. package/src/generators/init/generator.ts +0 -28
  20. package/src/generators/init/index.ts +0 -5
  21. package/src/generators/init/init-workspace.ts +0 -84
  22. package/src/generators/init-application/assert-main-statements.ts +0 -74
  23. package/src/generators/init-application/cleanup.ts +0 -127
  24. package/src/generators/init-application/coerce-app-config.ts +0 -147
  25. package/src/generators/init-application/coerce-environment-files.ts +0 -105
  26. package/src/generators/init-application/coerce-localazy-config-file.ts +0 -26
  27. package/src/generators/init-application/coerce-project.ts +0 -128
  28. package/src/generators/init-application/generate-authentication.ts +0 -122
  29. package/src/generators/init-application/generate-monolithic.spec.ts +0 -45
  30. package/src/generators/init-application/generate-monolithic.ts +0 -57
  31. package/src/generators/init-application/generator.ts +0 -356
  32. package/src/generators/init-application/index.ts +0 -5
  33. package/src/generators/init-application/link-mfe-remote-with-host.ts +0 -60
  34. package/src/generators/init-application/project-i18n-configuration.ts +0 -4
  35. package/src/generators/init-application/update-git-ignore.ts +0 -22
  36. package/src/generators/init-application/update-main-file.ts +0 -118
  37. package/src/generators/init-application/update-project-targets.ts +0 -229
  38. package/src/generators/init-application/update-tags.ts +0 -30
  39. package/src/generators/init-application/update-target-defaults.ts +0 -43
  40. package/src/generators/init-application/update-ts-config.ts +0 -31
  41. package/src/generators/init-component/generator.ts +0 -147
  42. package/src/generators/init-component/index.ts +0 -5
  43. package/src/generators/init-feature/generator.ts +0 -77
  44. package/src/generators/init-feature/index.ts +0 -5
  45. package/src/generators/init-feature-library/generator.ts +0 -82
  46. package/src/generators/init-feature-library/index.ts +0 -5
  47. package/src/generators/init-feature-library/init-project.ts +0 -53
  48. package/src/generators/init-feature-library/init-workspace.ts +0 -10
  49. package/src/generators/init-library/check-if-secondary-entrypoint-include-in-the-ts-config.ts +0 -46
  50. package/src/generators/init-library/cleanup.ts +0 -22
  51. package/src/generators/init-library/coerce-projects.ts +0 -118
  52. package/src/generators/init-library/coerce-tailwind-theme-scss.ts +0 -27
  53. package/src/generators/init-library/extend-angular-specific-eslint.ts +0 -37
  54. package/src/generators/init-library/generator.ts +0 -87
  55. package/src/generators/init-library/has-index-scss.ts +0 -14
  56. package/src/generators/init-library/has-tailwind-config.ts +0 -9
  57. package/src/generators/init-library/index.ts +0 -5
  58. package/src/generators/init-library/init-project.ts +0 -46
  59. package/src/generators/init-library/init-workspace.ts +0 -26
  60. package/src/generators/init-library/is-ng-packagr-project.ts +0 -9
  61. package/src/generators/init-library/ng-package-json.ts +0 -23
  62. package/src/generators/init-library/set-general-target-defaults.ts +0 -36
  63. package/src/generators/init-library/update-package-json.ts +0 -26
  64. package/src/generators/init-library/update-project-ng-package-configuration.ts +0 -51
  65. package/src/generators/init-library/update-ts-config.ts +0 -24
  66. package/src/generators/schematic/generator.ts +0 -179
  67. package/src/generators/schematic/index.ts +0 -5
  68. package/src/i18n.ts +0 -130
  69. package/src/index.ts +0 -3
  70. package/src/lib/angular-version.ts +0 -1
  71. package/src/lib/coerce-cypress-component-testing.ts +0 -113
  72. package/src/lib/coerce-test-setup.ts +0 -60
  73. package/src/library.ts +0 -153
  74. package/src/migrations/update-19-0-0/add-m2-prefix-to-material-scss-functions.ts +0 -32
  75. package/src/migrations/update-19-0-0/migration.ts +0 -283
  76. package/src/test-setup.ts +0 -24
  77. package/tsconfig.json +0 -20
  78. package/tsconfig.lib.json +0 -10
  79. package/tsconfig.spec.json +0 -15
  80. package/tsconfig.typedoc.json +0 -5
@@ -1,115 +0,0 @@
1
- # {{packageJson.name}}
2
- {{#if packageJson.description ~}}
3
- > {{packageJson.description}}
4
- {{/if}}
5
-
6
- [![npm version](https://img.shields.io/npm/v/{{packageJson.name}}?style=flat-square)](https://www.npmjs.com/package/{{packageJson.name}})
7
- [![commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=flat-square)](https://commitizen.github.io/cz-cli/)
8
- [![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
9
- ![Libraries.io dependency status for latest release, scoped npm package](https://img.shields.io/librariesio/release/npm/{{packageJson.name}})
10
- ![npm](https://img.shields.io/npm/dm/{{packageJson.name}})
11
- ![NPM](https://img.shields.io/npm/l/{{packageJson.name}})
12
-
13
- - [Installation](#installation)
14
- {{#if getStartedContent ~}}
15
- - [Get started](#get-started)
16
- {{/if}}
17
- {{#if guidesContent ~}}
18
- - [Guides](#guides)
19
- {{/if}}
20
- {{#if hasGenerators ~}}
21
- - [Generators](#generators)
22
- {{/if}}
23
- {{#if hasExecutors ~}}
24
- - [Executors](#executors)
25
- {{/if}}
26
-
27
- # Installation
28
-
29
- **Add the package to your workspace:**
30
- ```bash
31
- yarn add {{packageJson.name}}
32
- ```
33
- {{#if hasPeerDependencies ~}}
34
-
35
- **Install peer dependencies:**
36
- ```bash
37
- yarn add {{#each peerDependencyList}}{{this.name}}@{{this.version}} {{/each}}
38
- ```
39
- {{/if}}
40
- {{#if hasInitGenerator ~}}
41
-
42
- **Execute the init generator:**
43
- ```bash
44
- yarn nx g {{packageJson.name}}:init
45
- ```
46
- {{/if}}
47
- {{#if hasConfigGenerator ~}}
48
-
49
- **Execute the config generator to use the package with a project:**
50
- ```bash
51
- yarn nx g {{packageJson.name}}:config [project]
52
- ```
53
- {{/if}}
54
- {{#if getStartedContent ~}}
55
-
56
- # Get started
57
-
58
- {{{getStartedContent}}}
59
- {{/if}}
60
- {{#if guidesContent ~}}
61
-
62
- # Guides
63
-
64
- {{{guidesContent}}}
65
- {{/if}}
66
- {{#if hasGenerators ~}}
67
-
68
- # Generators
69
- {{#each generatorList}}
70
-
71
- ## {{this.name}}
72
- > {{this.description}}
73
-
74
- ```bash
75
- yarn nx g {{@root.packageJson.name}}:{{this.name}}
76
- ```
77
- {{#hasProperties this.schema.properties}}
78
-
79
- Option | Type | Default | Description
80
- --- | --- | --- | ---
81
- {{#each this.schema.properties}}
82
- {{@key}} | {{this.type}} | {{this.default}} | {{this.description}}
83
- {{/each}}
84
- {{/hasProperties}}
85
- {{/each}}
86
- {{/if}}
87
- {{#if hasExecutors ~}}
88
-
89
- # Executors
90
- {{#each executorsList}}
91
-
92
- ## {{this.name}}
93
- > {{this.description}}
94
-
95
- **project.json**
96
- ```json
97
- {
98
- "targets": {
99
- "{{this.name}}": {
100
- "executor": "{{@root.packageJson.name}}:{{this.name}}"
101
- }
102
- }
103
- }
104
- ```
105
- {{#hasProperties this.schema.properties}}
106
-
107
- Option | Type | Default | Description
108
- --- | --- | --- | ---
109
- {{#each this.schema.properties}}
110
- {{@key}} | {{this.type}} | {{this.default}} | {{this.description}}
111
- {{/each}}
112
- {{/hasProperties}}
113
- {{/each}}
114
-
115
- {{/if}}
package/jest.config.ts DELETED
@@ -1,11 +0,0 @@
1
- /* eslint-disable */
2
- export default {
3
- displayName: 'plugin-angular',
4
- preset: '../../../jest.preset.js',
5
- setupFilesAfterEnv: [ '<rootDir>/src/test-setup.ts' ],
6
- transform: {
7
- '^.+\\.[tj]s$': [ 'ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' } ],
8
- },
9
- moduleFileExtensions: [ 'ts', 'js', 'html' ],
10
- coverageDirectory: '../../../coverage/packages/plugin/angular',
11
- };
package/project.json DELETED
@@ -1,68 +0,0 @@
1
- {
2
- "name": "plugin-angular",
3
- "$schema": "../../../node_modules/nx/schemas/project-schema.json",
4
- "sourceRoot": "packages/plugin/angular/src",
5
- "projectType": "library",
6
- "tags": ["plugin", "nx", "nx-plugin", "packages"],
7
- "targets": {
8
- "build": {
9
- "executor": "@nx/js:tsc",
10
- "outputs": ["{options.outputPath}"],
11
- "options": {
12
- "outputPath": "dist/packages/plugin/angular",
13
- "main": "packages/plugin/angular/src/index.ts",
14
- "tsConfig": "packages/plugin/angular/tsconfig.lib.json",
15
- "generateExportsField": true,
16
- "additionalEntryPoints": [
17
- "packages/plugin/angular/src/library.ts",
18
- "packages/plugin/angular/src/application.ts",
19
- "packages/plugin/angular/src/i18n.ts"
20
- ],
21
- "assets": [
22
- "packages/plugin/angular/*.md",
23
- {
24
- "input": "./packages/plugin/angular/src",
25
- "glob": "**/!(*.ts)",
26
- "output": "./src"
27
- },
28
- {
29
- "input": "./packages/plugin/angular/src",
30
- "glob": "**/*.d.ts",
31
- "output": "./src"
32
- },
33
- {
34
- "input": "./packages/plugin/angular",
35
- "glob": "generators.json",
36
- "output": "."
37
- },
38
- {
39
- "input": "./packages/plugin/angular",
40
- "glob": "executors.json",
41
- "output": "."
42
- },
43
- {
44
- "input": "./packages/plugin/angular",
45
- "glob": "migrations.json",
46
- "output": "."
47
- },
48
- {
49
- "input": "./packages/plugin/angular/src/migrations",
50
- "glob": "**/!(*.ts|*.js|*.json)",
51
- "output": "./src/migrations"
52
- },
53
- "packages/plugin/angular/docs"
54
- ]
55
- }
56
- },
57
- "lint": {
58
- "options": {
59
- "lintFilePatterns": [
60
- "packages/plugin/angular/**/*.ts",
61
- "packages/plugin/angular/package.json",
62
- "packages/plugin/angular/generators.json",
63
- "packages/plugin/angular/executors.json"
64
- ]
65
- }
66
- }
67
- }
68
- }
package/schematics.yaml DELETED
@@ -1,6 +0,0 @@
1
- - package: "@rxap/plugin-library"
2
- name: init
3
- options: {}
4
- - package: "@rxap/plugin-typedoc"
5
- name: init-library
6
- options: {}
@@ -1,124 +0,0 @@
1
- import {
2
- CreateNodesContextV2,
3
- CreateNodesV2,
4
- ProjectConfiguration,
5
- TargetConfiguration,
6
- } from '@nx/devkit';
7
- import {
8
- FindProjectByPath,
9
- FsTree,
10
- } from '@rxap/workspace-utilities';
11
- import { Optional } from 'nx/src/project-graph/plugins';
12
- import { combineGlobPatterns } from 'nx/src/utils/globs';
13
- import { dirname } from 'path';
14
- import 'colors';
15
-
16
- // eslint-disable-next-line @typescript-eslint/no-empty-interface
17
- export interface PluginOptions {}
18
-
19
- export function normalizeOptions(
20
- options: PluginOptions | undefined,
21
- ): PluginOptions {
22
- return options ?? {};
23
- }
24
-
25
- export const createNodesV2: CreateNodesV2<PluginOptions> = [
26
- combineGlobPatterns([
27
- '**/tsconfig.app.json',
28
- '**/src/main.ts',
29
- '**/src/app/app.module.ts',
30
- '**/src/app/app.component.ts',
31
- '**/src/index.html',
32
- ]),
33
- async (configFilePaths, options, context) => {
34
- const normalizedOptions = normalizeOptions(options);
35
-
36
- const includedConfigFilePaths = await Promise.all(
37
- configFilePaths.map(async (configFilePath) => {
38
- if (
39
- await shouldHaveProjectConfiguration(
40
- configFilePath,
41
- normalizedOptions,
42
- context,
43
- )
44
- ) {
45
- return configFilePath;
46
- }
47
- return undefined;
48
- }),
49
- ).then((configFilePathOrUndefinedList) =>
50
- configFilePathOrUndefinedList.filter((value) => value !== undefined),
51
- );
52
-
53
- const results = await Promise.all(
54
- includedConfigFilePaths.map(async (configFilePath) => {
55
- const [ projectPath, projectConfiguration ] =
56
- await createProjectConfiguration(
57
- configFilePath,
58
- normalizedOptions,
59
- context,
60
- );
61
- return [ configFilePath, projectPath, projectConfiguration ] as [
62
- string,
63
- string,
64
- Optional<ProjectConfiguration, 'root'>
65
- ];
66
- }),
67
- );
68
-
69
- return results.map(
70
- ([ configFilePath, projectPath, projectConfiguration ]) => [
71
- configFilePath,
72
- {
73
- projects: {
74
- [projectPath]: projectConfiguration,
75
- },
76
- },
77
- ],
78
- );
79
- },
80
- ];
81
-
82
- async function shouldHaveProjectConfiguration(
83
- configFilePath: string,
84
- options: PluginOptions,
85
- context: CreateNodesContextV2,
86
- ): Promise<boolean> {
87
- const projectPath = dirname(configFilePath);
88
- const tree = new FsTree(context.workspaceRoot);
89
- if (!FindProjectByPath(tree, projectPath)) {
90
- // console.log(`The folder of the file '${ configFilePath }' is not the root of a project. Skipping`.yellow);
91
- return false;
92
- }
93
- return true;
94
- }
95
-
96
- async function createProjectConfiguration(
97
- configFilePath: string,
98
- options: PluginOptions,
99
- context: CreateNodesContextV2,
100
- ): Promise<[ string, Optional<ProjectConfiguration, 'root'> ]> {
101
- const projectPath = dirname(configFilePath);
102
- const targets: Record<string, TargetConfiguration> = {};
103
- const tree = new FsTree(context.workspaceRoot);
104
- const projectConfiguration = FindProjectByPath(tree, projectPath);
105
-
106
- if (!projectConfiguration) {
107
- throw new Error(`Could not find project in '${ projectPath }'`);
108
- }
109
-
110
- targets['config'] = createConfigTarget();
111
-
112
- return [
113
- projectPath, {
114
- targets,
115
- },
116
- ];
117
- }
118
-
119
- function createConfigTarget(): TargetConfiguration {
120
- return {
121
- executor: '@rxap/plugin-angular:config',
122
- dependsOn: ['build'],
123
- };
124
- }
@@ -1,33 +0,0 @@
1
- import { ExecutorContext } from '@nx/devkit';
2
- import { readFileFromProjectRoot } from '@rxap/plugin-utilities';
3
- import { CheckNgPackageExecutorSchema } from './schema';
4
-
5
- export default async function runExecutor(
6
- options: CheckNgPackageExecutorSchema,
7
- context: ExecutorContext,
8
- ) {
9
- console.log('Executor ran for CheckNgPackage', options);
10
-
11
- const ngPackage = JSON.parse(readFileFromProjectRoot(context, 'ng-package.json', true));
12
- const { dependencies } = JSON.parse(readFileFromProjectRoot(context, 'package.json', true));
13
-
14
- if (ngPackage.allowedNonPeerDependencies) {
15
- const wrongPackages: string[] = [];
16
- for (const packageName of ngPackage.allowedNonPeerDependencies) {
17
- if (!dependencies[packageName]) {
18
- wrongPackages.push(packageName);
19
- }
20
- }
21
- if (wrongPackages.length) {
22
- console.log(`\x1b[31mSome packages in the allowed non peer dependencies list are not in the package.json dependencies list:\x1b[0m\n - ${ wrongPackages.join(
23
- '\n - ') }`);
24
- return {
25
- success: false,
26
- };
27
- }
28
- }
29
-
30
- return {
31
- success: true,
32
- };
33
- }
@@ -1,74 +0,0 @@
1
- import { ExecutorContext } from '@nx/devkit';
2
- import { GuessOutputPathFromContext } from '@rxap/plugin-utilities';
3
- import {
4
- deepMerge,
5
- SetToObject,
6
- } from '@rxap/utilities';
7
- import {
8
- existsSync,
9
- readFileSync,
10
- writeFileSync,
11
- } from 'fs';
12
- import { join } from 'path';
13
- import { ConfigExecutorSchema } from './schema';
14
- import 'colors';
15
-
16
- function getContent(key: string) {
17
- const value = process.env[key];
18
- if (value) {
19
- let content: string;
20
- if (value.match(/^(\/[^/\s]*)+\/?$/)) {
21
- content = readFileSync(value).toString('utf-8');
22
- } else {
23
- content = value;
24
- }
25
- try {
26
- return JSON.parse(content);
27
- } catch (e: any) {
28
- throw new Error(`Can not parse config from '${ key }': ${ content }`);
29
- }
30
- }
31
- }
32
-
33
-
34
- export default async function runExecutor(
35
- options: ConfigExecutorSchema,
36
- context: ExecutorContext,
37
- ) {
38
- console.log('Executor ran for Config', options);
39
-
40
- const outputPath = GuessOutputPathFromContext(context);
41
-
42
- let config: any = {};
43
- const configPath = join(outputPath, 'config.json');
44
- if (existsSync(configPath)) {
45
- config = JSON.parse(readFileSync(configPath, 'utf-8'));
46
- }
47
-
48
- for (const key of Object.keys(process.env).filter(key => !!key && key.startsWith('RXAP_CONFIG')).sort((a, b) => a.length - b.length)) {
49
- try {
50
- const content = getContent(key);
51
- const match = key.match(/^RXAP_CONFIG_(.*)/);
52
- if (match) {
53
- const key = match[1].toLowerCase().replace(/_/g, '.');
54
- console.log(`Set config '${ key }'`.grey);
55
- SetToObject(config, key, content);
56
- } else {
57
- console.log('Merge config'.grey);
58
- deepMerge(config, content);
59
- }
60
- } catch (e: any) {
61
- console.error(e.message);
62
- return {
63
- success: false,
64
- error: e.message,
65
- };
66
- }
67
- }
68
-
69
- writeFileSync(configPath, JSON.stringify(config, null, 2));
70
-
71
- return {
72
- success: true,
73
- };
74
- }
@@ -1,198 +0,0 @@
1
- import { ExecutorContext } from '@nx/devkit';
2
- import {
3
- GetProjectSourceRoot,
4
- GetProjectTargetOptions,
5
- GuessOutputPathFromTargetString,
6
- } from '@rxap/plugin-utilities';
7
- import {
8
- existsSync,
9
- readFileSync,
10
- writeFileSync,
11
- } from 'fs';
12
- import { copy } from 'fs-extra';
13
- import { glob } from 'glob';
14
- import { compile } from 'handlebars';
15
- import {
16
- basename,
17
- join,
18
- relative,
19
- } from 'path';
20
- import { I18nExecutorSchema } from './schema';
21
-
22
- function getIndexHtmlTemplateFilePath(indexHtmlTemplate: string, context: ExecutorContext) {
23
- if (existsSync(join(context.root, indexHtmlTemplate))) {
24
- return join(context.root, indexHtmlTemplate);
25
- }
26
- if (existsSync(join(context.root, 'shared', indexHtmlTemplate))) {
27
- return join(context.root, 'shared', indexHtmlTemplate);
28
- }
29
- if (existsSync(join(context.root, 'shared', 'angular', indexHtmlTemplate))) {
30
- return join(context.root, 'shared', 'angular', indexHtmlTemplate);
31
- }
32
- const projectSourceRoot = GetProjectSourceRoot(context);
33
- if (existsSync(join(projectSourceRoot, indexHtmlTemplate))) {
34
- return join(projectSourceRoot, indexHtmlTemplate);
35
- }
36
- throw new Error(`Could not find the i18n index html template with path '${ indexHtmlTemplate }'`);
37
- }
38
-
39
- async function createIndexHtml(
40
- options: I18nExecutorSchema,
41
- context: ExecutorContext,
42
- outputPath: string,
43
- ) {
44
- const indexHtmlTemplateFilePath = options.indexHtmlTemplate ?? 'i18n.index.html.hbs';
45
-
46
- if (!indexHtmlTemplateFilePath) {
47
- throw new Error('The i18n index html template path is not defined');
48
- }
49
-
50
- const indexHtmlTemplateAbsoluteFilePath = getIndexHtmlTemplateFilePath(indexHtmlTemplateFilePath, context);
51
-
52
- const indexHtmlTemplateFile = readFileSync(indexHtmlTemplateAbsoluteFilePath).toString('utf-8');
53
-
54
- const indexHtmlTemplate = compile(indexHtmlTemplateFile);
55
-
56
- const indexHtml = indexHtmlTemplate(options);
57
-
58
- const indexHtmlFilePath = join(context.root, outputPath, 'index.html');
59
-
60
- if (existsSync(indexHtmlFilePath)) {
61
- console.warn(`The index.html file already exists in the location: '${ indexHtmlFilePath }'`);
62
- }
63
-
64
- writeFileSync(indexHtmlFilePath, indexHtml);
65
- }
66
-
67
- async function copyFiles(
68
- outputPath: string,
69
- pathList: Array<string | { glob: string, input: string, output: string }>,
70
- ) {
71
- await Promise.all(pathList.map(async assetPath => {
72
- if (typeof assetPath === 'string') {
73
- if (!outputPath) {
74
- throw new Error('The i18n output path is not defined');
75
- }
76
- const assetOutputPath = join(outputPath, basename(assetPath));
77
- try {
78
- await copy(assetPath, assetOutputPath);
79
- } catch (e: any) {
80
- throw new Error(`Could not copy assets '${ assetPath }' to '${ outputPath }': ${ e.message }`);
81
- }
82
- } else {
83
- if (!outputPath) {
84
- throw new Error('The i18n output path is not defined');
85
- }
86
- const assetOutputPath = join(outputPath, assetPath.output);
87
- try {
88
- const files = await glob(assetPath.input + assetPath.glob);
89
- await Promise.all(files.map(file => copy(file, join(assetOutputPath, relative(assetPath.input, file)))));
90
- } catch (e: any) {
91
- throw new Error(`Could not copy assets '${ JSON.stringify(assetPath) }' to '${ outputPath }': ${ e.message }`);
92
- }
93
- }
94
- }));
95
- }
96
-
97
- async function copyAssets(
98
- outputPath: string,
99
- options: I18nExecutorSchema,
100
- context: ExecutorContext,
101
- ) {
102
-
103
- if (Array.isArray(options.assets) && options.assets.length) {
104
- await copyFiles(outputPath, options.assets);
105
- } else if (typeof options.assets === 'boolean' && options.assets) {
106
-
107
- if (!context.target) {
108
- throw new Error('The current builder target is not defined in the context');
109
- }
110
-
111
- if (!context.projectName) {
112
- throw new Error('The current project name is not defined in the context');
113
- }
114
-
115
- const buildOptions = GetProjectTargetOptions(context, context.projectName, 'build');
116
-
117
- if (Array.isArray(buildOptions.assets) && buildOptions.assets.length) {
118
- await copyFiles(outputPath, buildOptions.assets);
119
- } else {
120
- console.info('Skip assets copy. The build target of this project has no assets specified.');
121
- }
122
-
123
- } else {
124
- console.info('Skip assets copy. No assets specified.');
125
- }
126
-
127
- }
128
-
129
- function coerceDefaultLanguage(options: I18nExecutorSchema) {
130
- options.defaultLanguage ??= options.availableLanguages?.[0];
131
- }
132
-
133
- function coerceAvailableLanguages(options: I18nExecutorSchema, context: ExecutorContext) {
134
-
135
- if (!options.availableLanguages) {
136
- const buildTarget = options.buildTarget ?? context.projectName + ':build';
137
- const targetName = buildTarget.split(':')[1];
138
- const buildOptions = GetProjectTargetOptions(
139
- context,
140
- context.projectName,
141
- targetName,
142
- context.configurationName ?? 'production'
143
- );
144
- const localize = buildOptions.localize;
145
- if (localize && Array.isArray(localize) && localize.length) {
146
- options.availableLanguages = localize;
147
- } else if (options.defaultLanguage) {
148
- options.availableLanguages = [ options.defaultLanguage ];
149
- }
150
-
151
- }
152
-
153
- }
154
-
155
- export default async function runExecutor(
156
- options: I18nExecutorSchema,
157
- context: ExecutorContext,
158
- ) {
159
- console.log('Executor ran for I18n', options);
160
-
161
- coerceAvailableLanguages(options, context);
162
-
163
- if (!options.availableLanguages?.length) {
164
- throw new Error('The available languages are not defined');
165
- }
166
-
167
- coerceDefaultLanguage(options);
168
-
169
- if (!options.defaultLanguage) {
170
- throw new Error('The default language is not defined');
171
- }
172
-
173
- const outputPath = GuessOutputPathFromTargetString(context, options.buildTarget);
174
-
175
- try {
176
- await createIndexHtml(options, context, outputPath);
177
- } catch (e: any) {
178
- console.error(`Create index html failed: ${e.message}`);
179
- return {
180
- success: false,
181
- error: e.message,
182
- };
183
- }
184
-
185
- try {
186
- await copyAssets(outputPath, options, context);
187
- } catch (e: any) {
188
- console.error(`Copy assets failed: ${ e.message }`);
189
- return {
190
- success: false,
191
- error: e.message,
192
- };
193
- }
194
-
195
- return {
196
- success: true,
197
- };
198
- }
@@ -1,34 +0,0 @@
1
- import { ExecutorContext } from '@nx/devkit';
2
- import { GetProjectRoot } from '@rxap/plugin-utilities';
3
- import { join } from 'path';
4
- // @ts-expect-error - Tailwindcss does not have types
5
- import { build } from 'tailwindcss/lib/cli/build';
6
- import { TailwindExecutorSchema } from './schema';
7
-
8
- export default async function runExecutor(options: TailwindExecutorSchema, context: ExecutorContext) {
9
- console.log('Executor ran for Tailwind', options);
10
-
11
- const projectRoot = GetProjectRoot(context);
12
-
13
- const args: Record<string, string | boolean | number> = {
14
- '--config': join(projectRoot, options.config),
15
- '--input': join(projectRoot, options.input),
16
- '--output': join(projectRoot, options.output),
17
- };
18
-
19
- if (options.minify) {
20
- args['--minify'] = true;
21
- }
22
-
23
- console.log('Running Tailwind with args', JSON.stringify(args, undefined, 2));
24
-
25
- await build(args);
26
-
27
- return { success: true };
28
-
29
- // return run({
30
- // cwd: projectRoot,
31
- // command,
32
- // __unparsed__: [],
33
- // }, context);
34
- }