@blotch/angular-lynx 22.2.1 → 22.2.3
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/README.md +3 -1
- package/fesm2022/blotch-angular-lynx-web-glass-8MFrhPz0.mjs +951 -0
- package/fesm2022/blotch-angular-lynx-web-glass-8MFrhPz0.mjs.map +1 -0
- package/fesm2022/blotch-angular-lynx.mjs +8084 -0
- package/fesm2022/blotch-angular-lynx.mjs.map +1 -0
- package/package.json +11 -6
- package/schematics/add-i18n/index.js +168 -0
- package/schematics/add-i18n/schema.js +2 -0
- package/schematics/add-tailwind/index.js +100 -0
- package/schematics/add-tailwind/schema.js +2 -0
- package/schematics/add-testing/index.js +80 -0
- package/schematics/add-testing/schema.js +2 -0
- package/schematics/collection.json +7 -2
- package/schematics/component/index.js +110 -0
- package/schematics/component/schema.js +2 -0
- package/schematics/component/schema.json +102 -25
- package/schematics/eject/index.js +87 -0
- package/schematics/eject/schema.js +2 -0
- package/schematics/eject/schema.json +24 -0
- package/schematics/files/src/rspeedy-env.d.ts.template +1 -1
- package/schematics/migrations/accessibility-traits/index.js +56 -0
- package/schematics/migrations/dev-logs-gitignore/index.js +9 -0
- package/schematics/migrations/extract-i18n-target/index.js +31 -0
- package/schematics/migrations/tailwind-html-templates/index.js +44 -0
- package/schematics/migrations.json +25 -0
- package/schematics/ng-add/index.js +480 -0
- package/schematics/ng-add/schema.js +2 -0
- package/schematics/ng-add/schema.json +6 -2
- package/schematics/ng-add/versions.js +57 -0
- package/schematics/package.json +3 -0
- package/schematics/utility/dev-logs-gitignore.js +25 -0
- package/schematics/utility/extract-i18n-target.js +58 -0
- package/types/blotch-angular-lynx.d.ts +4789 -0
- package/schematics/files/lynx.config.ts.template +0 -17
|
@@ -2,58 +2,135 @@
|
|
|
2
2
|
"$schema": "http://json-schema.org/draft-07/schema",
|
|
3
3
|
"$id": "SchematicsAngularLynxComponent",
|
|
4
4
|
"title": "AngularLynx component schematic",
|
|
5
|
+
"description": "Generates a component with Angular's component schematic, then makes it a Lynx one: its template uses Lynx elements and it imports LYNX_ELEMENTS. The options are Angular's (a test keeps them in step); left out, they take the defaults angular.json sets for @schematics/angular:component, then Angular's.",
|
|
5
6
|
"type": "object",
|
|
6
7
|
"additionalProperties": false,
|
|
7
|
-
"description": "Generates a standalone Angular component with Lynx element template.",
|
|
8
8
|
"properties": {
|
|
9
|
-
"name": {
|
|
10
|
-
"type": "string",
|
|
11
|
-
"description": "The name of the component.",
|
|
12
|
-
"$default": {
|
|
13
|
-
"$source": "argv",
|
|
14
|
-
"index": 0
|
|
15
|
-
},
|
|
16
|
-
"x-prompt": "What name would you like to use for the component?"
|
|
17
|
-
},
|
|
18
9
|
"path": {
|
|
19
10
|
"type": "string",
|
|
20
11
|
"format": "path",
|
|
21
|
-
"
|
|
12
|
+
"$default": {
|
|
13
|
+
"$source": "workingDirectory"
|
|
14
|
+
},
|
|
15
|
+
"description": "The path where the component files should be created, relative to the current workspace. If not provided, a folder with the same name as the component will be created in the project's `src/app` directory.",
|
|
22
16
|
"visible": false
|
|
23
17
|
},
|
|
24
18
|
"project": {
|
|
25
19
|
"type": "string",
|
|
26
|
-
"description": "The name of the project.",
|
|
20
|
+
"description": "The name of the project where the component should be added. If not specified, the CLI will determine the project from the current directory.",
|
|
27
21
|
"$default": {
|
|
28
22
|
"$source": "projectName"
|
|
29
23
|
}
|
|
30
24
|
},
|
|
31
|
-
"
|
|
25
|
+
"name": {
|
|
32
26
|
"type": "string",
|
|
33
|
-
"description": "The
|
|
27
|
+
"description": "The name for the new component. This will be used to create the component's class, template, and stylesheet files. For example, if you provide `my-component`, the files will be named `my-component.ts`, `my-component.html`, and `my-component.css`.",
|
|
28
|
+
"$default": {
|
|
29
|
+
"$source": "argv",
|
|
30
|
+
"index": 0
|
|
31
|
+
},
|
|
32
|
+
"x-prompt": "What name would you like to use for the component?"
|
|
33
|
+
},
|
|
34
|
+
"displayBlock": {
|
|
35
|
+
"description": "Adds `:host { display: block; }` to the component's stylesheet, ensuring the component renders as a block-level element. This is useful for layout purposes.",
|
|
36
|
+
"type": "boolean",
|
|
37
|
+
"alias": "b"
|
|
34
38
|
},
|
|
35
39
|
"inlineStyle": {
|
|
40
|
+
"description": "Include the component's styles directly in the `component.ts` file. By default, a separate stylesheet file (e.g., `my-component.css`) is created.",
|
|
36
41
|
"type": "boolean",
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"alias": "s"
|
|
42
|
+
"alias": "s",
|
|
43
|
+
"x-user-analytics": "ep.ng_inline_style"
|
|
40
44
|
},
|
|
41
45
|
"inlineTemplate": {
|
|
46
|
+
"description": "Include the component's HTML template directly in the `component.ts` file. By default, a separate template file (e.g., `my-component.html`) is created.",
|
|
47
|
+
"type": "boolean",
|
|
48
|
+
"alias": "t",
|
|
49
|
+
"x-user-analytics": "ep.ng_inline_template"
|
|
50
|
+
},
|
|
51
|
+
"standalone": {
|
|
52
|
+
"description": "Generate a standalone component. Standalone components are self-contained and don't need to be declared in an NgModule. They can be used independently or imported directly into other standalone components.",
|
|
53
|
+
"type": "boolean",
|
|
54
|
+
"x-user-analytics": "ep.ng_standalone"
|
|
55
|
+
},
|
|
56
|
+
"viewEncapsulation": {
|
|
57
|
+
"description": "Sets the view encapsulation mode for the component. This determines how the component's styles are scoped and applied.",
|
|
58
|
+
"enum": ["Emulated", "None", "ShadowDom"],
|
|
59
|
+
"type": "string",
|
|
60
|
+
"alias": "v"
|
|
61
|
+
},
|
|
62
|
+
"changeDetection": {
|
|
63
|
+
"description": "Configures the change detection strategy for the component.",
|
|
64
|
+
"enum": ["Eager", "OnPush"],
|
|
65
|
+
"type": "string",
|
|
66
|
+
"alias": "c"
|
|
67
|
+
},
|
|
68
|
+
"prefix": {
|
|
69
|
+
"type": "string",
|
|
70
|
+
"description": "A prefix to be added to the component's selector. For example, if the prefix is `app` and the component name is `my-component`, the selector will be `app-my-component`.",
|
|
71
|
+
"alias": "p",
|
|
72
|
+
"oneOf": [
|
|
73
|
+
{
|
|
74
|
+
"maxLength": 0
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"minLength": 1,
|
|
78
|
+
"format": "html-selector"
|
|
79
|
+
}
|
|
80
|
+
]
|
|
81
|
+
},
|
|
82
|
+
"style": {
|
|
83
|
+
"description": "Specify the type of stylesheet to be created for the component, or `none` to skip creating a stylesheet.",
|
|
84
|
+
"type": "string",
|
|
85
|
+
"enum": ["css", "scss", "sass", "less", "none"],
|
|
86
|
+
"x-user-analytics": "ep.ng_style"
|
|
87
|
+
},
|
|
88
|
+
"type": {
|
|
89
|
+
"type": "string",
|
|
90
|
+
"description": "Append a custom type to the component's filename. For example, if you set the type to `container`, the file will be named `my-component.container.ts`."
|
|
91
|
+
},
|
|
92
|
+
"addTypeToClassName": {
|
|
42
93
|
"type": "boolean",
|
|
43
|
-
"description": "
|
|
44
|
-
"default": true,
|
|
45
|
-
"alias": "t"
|
|
94
|
+
"description": "When true, the 'type' option will be appended to the generated class name. When false, only the file name will include the type."
|
|
46
95
|
},
|
|
47
96
|
"skipTests": {
|
|
48
97
|
"type": "boolean",
|
|
49
|
-
"description": "
|
|
50
|
-
"default": false
|
|
98
|
+
"description": "Skip the generation of unit test files `spec.ts`."
|
|
51
99
|
},
|
|
52
100
|
"flat": {
|
|
53
101
|
"type": "boolean",
|
|
54
|
-
"description": "Create the component files
|
|
55
|
-
|
|
102
|
+
"description": "Create the component files directly in the project's `src/app` directory instead of creating a new folder for them."
|
|
103
|
+
},
|
|
104
|
+
"skipImport": {
|
|
105
|
+
"type": "boolean",
|
|
106
|
+
"description": "Do not automatically import the new component into its closest NgModule."
|
|
107
|
+
},
|
|
108
|
+
"selector": {
|
|
109
|
+
"type": "string",
|
|
110
|
+
"format": "html-selector",
|
|
111
|
+
"description": "The HTML selector to use for this component. If not provided, a selector will be generated based on the component name (e.g., `app-my-component`)."
|
|
112
|
+
},
|
|
113
|
+
"skipSelector": {
|
|
114
|
+
"type": "boolean",
|
|
115
|
+
"description": "Skip the generation of an HTML selector for the component."
|
|
116
|
+
},
|
|
117
|
+
"module": {
|
|
118
|
+
"type": "string",
|
|
119
|
+
"description": "Specify the NgModule where the component should be declared. If not provided, the CLI will attempt to find the closest NgModule in the component's path.",
|
|
120
|
+
"alias": "m"
|
|
121
|
+
},
|
|
122
|
+
"export": {
|
|
123
|
+
"type": "boolean",
|
|
124
|
+
"description": "Automatically export the component from the specified NgModule, making it accessible to other modules in the application."
|
|
125
|
+
},
|
|
126
|
+
"exportDefault": {
|
|
127
|
+
"type": "boolean",
|
|
128
|
+
"description": "Use a default export for the component in its TypeScript file instead of a named export."
|
|
129
|
+
},
|
|
130
|
+
"ngHtml": {
|
|
131
|
+
"type": "boolean",
|
|
132
|
+
"description": "Generate component template files with an '.ng.html' file extension instead of '.html'."
|
|
56
133
|
}
|
|
57
134
|
},
|
|
58
|
-
"required": ["name"]
|
|
135
|
+
"required": ["name", "project"]
|
|
59
136
|
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
5
|
+
const workspace_1 = require("@schematics/angular/utility/workspace");
|
|
6
|
+
const node_fs_1 = require("node:fs");
|
|
7
|
+
const node_module_1 = require("node:module");
|
|
8
|
+
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
9
|
+
const node_url_1 = require("node:url");
|
|
10
|
+
/**
|
|
11
|
+
* A real dynamic import. The schematics compile to CommonJS, where TypeScript
|
|
12
|
+
* rewrites `import()` into `require()`, and the native builder is ESM-only
|
|
13
|
+
* (the same reason Angular CLI keeps its own `loadEsmModule`).
|
|
14
|
+
*/
|
|
15
|
+
const importEsm = new Function('specifier', 'return import(specifier)');
|
|
16
|
+
/**
|
|
17
|
+
* Loads the native builder that `ng build --platform` uses, so the ejected
|
|
18
|
+
* project is exactly the one it would have generated. It is a dependency of
|
|
19
|
+
* @blotch/angular-lynx-build rather than of the app, so it is resolved from
|
|
20
|
+
* there: pnpm doesn't link it into the app's own node_modules.
|
|
21
|
+
*/
|
|
22
|
+
const loadNative = async (workspaceRoot) => {
|
|
23
|
+
const fromApp = (0, node_module_1.createRequire)(node_path_1.default.join(workspaceRoot, 'package.json'));
|
|
24
|
+
let buildersPackageJson;
|
|
25
|
+
try {
|
|
26
|
+
buildersPackageJson = (0, node_fs_1.realpathSync)(fromApp.resolve('@blotch/angular-lynx-build/package.json'));
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
throw new schematics_1.SchematicsException('@blotch/angular-lynx-build is not installed. Install it first: npm install --save-dev @blotch/angular-lynx-build');
|
|
30
|
+
}
|
|
31
|
+
const packageJsonPath = (0, node_module_1.createRequire)(buildersPackageJson).resolve('@blotch/angular-lynx-native/package.json');
|
|
32
|
+
const entry = JSON.parse((0, node_fs_1.readFileSync)(packageJsonPath, 'utf8')).exports['.']
|
|
33
|
+
.import;
|
|
34
|
+
return (await importEsm((0, node_url_1.pathToFileURL)(node_path_1.default.join(node_path_1.default.dirname(packageJsonPath), entry)).href));
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* `ng generate @blotch/angular-lynx:eject`: writes the native projects that
|
|
38
|
+
* `ng build --platform` generates into `ios/` and `android/`, for apps that
|
|
39
|
+
* need native changes the builder options don't cover. The builder then
|
|
40
|
+
* builds those folders as they are.
|
|
41
|
+
*
|
|
42
|
+
* One-way on purpose, like Expo's bare workflow: once a project is ejected,
|
|
43
|
+
* keeping it in step with Lynx, Xcode and Google Play is the app's job.
|
|
44
|
+
*/
|
|
45
|
+
exports.default = (options) => async (tree, context) => {
|
|
46
|
+
const workspace = await (0, workspace_1.getWorkspace)(tree);
|
|
47
|
+
const projectName = options.project ?? [...workspace.projects.keys()][0];
|
|
48
|
+
const project = projectName
|
|
49
|
+
? workspace.projects.get(projectName)
|
|
50
|
+
: undefined;
|
|
51
|
+
if (!projectName || !project) {
|
|
52
|
+
throw new schematics_1.SchematicsException(`Project "${options.project ?? ''}" not found in angular.json.`);
|
|
53
|
+
}
|
|
54
|
+
const projectRoot = project.root;
|
|
55
|
+
const platforms = !options.platform || options.platform === 'all'
|
|
56
|
+
? ['ios', 'android']
|
|
57
|
+
: [options.platform];
|
|
58
|
+
for (const platform of platforms) {
|
|
59
|
+
const dir = node_path_1.default.posix.join(projectRoot || '', platform);
|
|
60
|
+
if (tree.getDir(dir).subfiles.length > 0 ||
|
|
61
|
+
tree.getDir(dir).subdirs.length > 0) {
|
|
62
|
+
throw new schematics_1.SchematicsException(`${dir}/ already exists. Delete it first to eject ${platform} again.`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
// The schematic runs from the workspace root, where Angular CLI resolved
|
|
66
|
+
// this package too.
|
|
67
|
+
const workspaceRoot = process.cwd();
|
|
68
|
+
const native = await loadNative(workspaceRoot);
|
|
69
|
+
const app = (project.targets.get('build')?.options ?? {});
|
|
70
|
+
const packageVersion = tree.exists('/package.json')
|
|
71
|
+
? JSON.parse(tree.readText('/package.json')).version
|
|
72
|
+
: undefined;
|
|
73
|
+
for (const platform of platforms) {
|
|
74
|
+
const files = native.renderEjectedProject({
|
|
75
|
+
platform,
|
|
76
|
+
projectRoot: node_path_1.default.join(workspaceRoot, projectRoot),
|
|
77
|
+
projectName,
|
|
78
|
+
packageVersion,
|
|
79
|
+
app,
|
|
80
|
+
generatorVersion: native.PACKAGE_VERSION,
|
|
81
|
+
});
|
|
82
|
+
for (const [file, content] of files) {
|
|
83
|
+
tree.create(node_path_1.default.posix.join(projectRoot || '', platform, file), content);
|
|
84
|
+
}
|
|
85
|
+
context.logger.info(`Ejected ${platform}/. \`ng build --platform ${platform}\` now builds it as it is: edit it freely, but angular.json app options no longer apply to it, and Lynx, Xcode and Google Play upgrades are yours to make.`);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema",
|
|
3
|
+
"$id": "SchematicsAngularLynxEject",
|
|
4
|
+
"title": "AngularLynx eject schematic",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"additionalProperties": false,
|
|
7
|
+
"description": "Writes the generated iOS and Android projects into ios/ and android/, where you own and edit them. One-way: angular.json app options stop applying to an ejected project.",
|
|
8
|
+
"properties": {
|
|
9
|
+
"project": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"description": "The project to eject.",
|
|
12
|
+
"$default": {
|
|
13
|
+
"$source": "projectName"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"platform": {
|
|
17
|
+
"type": "string",
|
|
18
|
+
"enum": ["ios", "android", "all"],
|
|
19
|
+
"default": "all",
|
|
20
|
+
"description": "Which native project to eject."
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"required": []
|
|
24
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
/// <reference types="@lynx-
|
|
1
|
+
/// <reference types="@blotch/angular-lynx-build/client" />
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const workspace_1 = require("@schematics/angular/utility/workspace");
|
|
4
|
+
/**
|
|
5
|
+
* The singular name, as an attribute, a binding (`[accessibility-trait]`,
|
|
6
|
+
* `[attr.accessibility-trait]`) or a string, but not part of a longer name
|
|
7
|
+
* such as `accessibility-traits`.
|
|
8
|
+
*/
|
|
9
|
+
const SINGULAR = /(?<![\w-])accessibility-trait(?![\w-])/g;
|
|
10
|
+
/** Folders that hold no source of the app's own. */
|
|
11
|
+
const SKIPPED_DIRS = new Set(['node_modules', 'dist']);
|
|
12
|
+
/**
|
|
13
|
+
* Calls `visit` with the path of every template and TypeScript file under
|
|
14
|
+
* `dir`, skipping dependencies, build output and dot folders.
|
|
15
|
+
*/
|
|
16
|
+
const visitSources = (dir, visit) => {
|
|
17
|
+
for (const file of dir.subfiles) {
|
|
18
|
+
if (/\.(html|ts)$/.test(file) && !file.endsWith('.d.ts')) {
|
|
19
|
+
visit(dir.file(file).path);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
for (const sub of dir.subdirs) {
|
|
23
|
+
if (!SKIPPED_DIRS.has(sub) && !sub.startsWith('.')) {
|
|
24
|
+
visitSources(dir.dir(sub), visit);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Renames `accessibility-trait` to `accessibility-traits` in the app's
|
|
30
|
+
* templates.
|
|
31
|
+
*
|
|
32
|
+
* `LYNX_ELEMENTS` declared the input in the singular, but iOS, Android and
|
|
33
|
+
* Harmony read only the plural, so the attribute did nothing. Now the input
|
|
34
|
+
* is `accessibility-traits`, and a `[accessibility-trait]` binding no longer
|
|
35
|
+
* compiles. This renames both the bindings and the static attributes, in
|
|
36
|
+
* `.html` templates and in the `.ts` files that hold inline ones.
|
|
37
|
+
*/
|
|
38
|
+
exports.default = () => async (tree) => {
|
|
39
|
+
const workspace = await (0, workspace_1.getWorkspace)(tree);
|
|
40
|
+
const roots = new Set([
|
|
41
|
+
'',
|
|
42
|
+
...[...workspace.projects.values()].map((project) => project.root),
|
|
43
|
+
]);
|
|
44
|
+
// The workspace root takes in the projects under it, so a file can come up
|
|
45
|
+
// from more than one root.
|
|
46
|
+
const files = new Set();
|
|
47
|
+
for (const root of roots) {
|
|
48
|
+
visitSources(tree.getDir(root), (path) => files.add(path));
|
|
49
|
+
}
|
|
50
|
+
for (const file of files) {
|
|
51
|
+
const text = tree.readText(file);
|
|
52
|
+
const updated = text.replace(SINGULAR, 'accessibility-traits');
|
|
53
|
+
if (updated !== text)
|
|
54
|
+
tree.overwrite(file, updated);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const dev_logs_gitignore_1 = require("../../utility/dev-logs-gitignore");
|
|
4
|
+
/**
|
|
5
|
+
* Adds `.dev-logs`, where `ng serve` writes `LynxLogger`'s output, to the
|
|
6
|
+
* workspace's `.gitignore`. `ng add` now adds it to new apps; apps made before
|
|
7
|
+
* left it to the app, as the debugging guide said.
|
|
8
|
+
*/
|
|
9
|
+
exports.default = () => (0, dev_logs_gitignore_1.ignoreDevLogs)();
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const workspace_1 = require("@schematics/angular/utility/workspace");
|
|
4
|
+
const extract_i18n_target_1 = require("../../utility/extract-i18n-target");
|
|
5
|
+
/**
|
|
6
|
+
* Gives every AngularLynx app in the workspace an `extract-i18n` target.
|
|
7
|
+
*
|
|
8
|
+
* Angular CLI can't pick an extractor for the Lynx build builder by itself,
|
|
9
|
+
* and neither `ng add` nor `add-i18n` wrote a target, so `ng extract-i18n`
|
|
10
|
+
* failed with "Cannot determine project or target for command." Now both
|
|
11
|
+
* write one with the AngularLynx extract-i18n builder. This gives an app made
|
|
12
|
+
* before the target those schematics would write today: `add-i18n`'s (JSON
|
|
13
|
+
* in `src/locale`) when the app has an `i18n` block in angular.json, and
|
|
14
|
+
* `ng add`'s (Angular's defaults) otherwise. A target the app added by hand
|
|
15
|
+
* with Angular's builder, as the i18n guide showed, switches to the Lynx one,
|
|
16
|
+
* which also handles imported images, and its options stay as they are: the
|
|
17
|
+
* app already extracts the format it chose.
|
|
18
|
+
*/
|
|
19
|
+
exports.default = () => (0, workspace_1.updateWorkspace)((workspace) => {
|
|
20
|
+
for (const project of workspace.projects.values()) {
|
|
21
|
+
if (project.targets.get('build')?.builder !==
|
|
22
|
+
'@blotch/angular-lynx-build:application') {
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
const sourceRoot = project.sourceRoot ?? (project.root ? `${project.root}/src` : 'src');
|
|
26
|
+
const isNew = !project.targets.has('extract-i18n');
|
|
27
|
+
(0, extract_i18n_target_1.useLynxExtractI18n)(project, isNew && project.extensions['i18n']
|
|
28
|
+
? (0, extract_i18n_target_1.jsonMessagesOptions)(sourceRoot)
|
|
29
|
+
: {});
|
|
30
|
+
}
|
|
31
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const workspace_1 = require("@schematics/angular/utility/workspace");
|
|
4
|
+
/** The Tailwind config files the build looks for. */
|
|
5
|
+
const CONFIG_FILES = [
|
|
6
|
+
'tailwind.config.ts',
|
|
7
|
+
'tailwind.config.js',
|
|
8
|
+
'tailwind.config.mjs',
|
|
9
|
+
'tailwind.config.cjs',
|
|
10
|
+
];
|
|
11
|
+
/**
|
|
12
|
+
* The `content` glob that `ng add` and `add-tailwind` wrote, in either quote.
|
|
13
|
+
*/
|
|
14
|
+
const TS_ONLY_GLOB = /(['"])\.\/src\/\*\*\/\*\.ts\1/g;
|
|
15
|
+
/**
|
|
16
|
+
* Adds `.html` templates to the Tailwind `content` glob the schematics wrote.
|
|
17
|
+
*
|
|
18
|
+
* The build used to scan the modules it bundled instead of `content`, so the
|
|
19
|
+
* glob didn't matter, and classes used only in `.html` templates got no CSS.
|
|
20
|
+
* Now the build runs Tailwind with `content`, as Angular's own Tailwind setup
|
|
21
|
+
* does, and the schematics write `./src/**\/*.{html,ts}`. This brings the
|
|
22
|
+
* glob of an app made before up to date. A glob the app changed is left
|
|
23
|
+
* alone.
|
|
24
|
+
*/
|
|
25
|
+
exports.default = () => async (tree) => {
|
|
26
|
+
const workspace = await (0, workspace_1.getWorkspace)(tree);
|
|
27
|
+
// The schematics write the config at the project root, which is the
|
|
28
|
+
// workspace root for an app made by `ng new`.
|
|
29
|
+
const roots = new Set([
|
|
30
|
+
'',
|
|
31
|
+
...[...workspace.projects.values()].map((project) => project.root),
|
|
32
|
+
]);
|
|
33
|
+
for (const root of roots) {
|
|
34
|
+
for (const name of CONFIG_FILES) {
|
|
35
|
+
const file = root ? `${root}/${name}` : name;
|
|
36
|
+
if (!tree.exists(file))
|
|
37
|
+
continue;
|
|
38
|
+
const text = tree.readText(file);
|
|
39
|
+
const updated = text.replace(TS_ONLY_GLOB, (_glob, quote) => `${quote}./src/**/*.{html,ts}${quote}`);
|
|
40
|
+
if (updated !== text)
|
|
41
|
+
tree.overwrite(file, updated);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "../node_modules/@angular-devkit/schematics/collection-schema.json",
|
|
3
|
+
"schematics": {
|
|
4
|
+
"tailwind-html-templates": {
|
|
5
|
+
"version": "22.2.3",
|
|
6
|
+
"description": "Adds .html templates to the Tailwind content glob, which the build now reads",
|
|
7
|
+
"factory": "./migrations/tailwind-html-templates/index"
|
|
8
|
+
},
|
|
9
|
+
"accessibility-traits": {
|
|
10
|
+
"version": "22.2.3",
|
|
11
|
+
"description": "Renames accessibility-trait, which Lynx ignores, to accessibility-traits",
|
|
12
|
+
"factory": "./migrations/accessibility-traits/index"
|
|
13
|
+
},
|
|
14
|
+
"extract-i18n-target": {
|
|
15
|
+
"version": "22.2.3",
|
|
16
|
+
"description": "Adds the extract-i18n target that ng extract-i18n needs, with the AngularLynx builder",
|
|
17
|
+
"factory": "./migrations/extract-i18n-target/index"
|
|
18
|
+
},
|
|
19
|
+
"dev-logs-gitignore": {
|
|
20
|
+
"version": "22.2.3",
|
|
21
|
+
"description": "Adds .dev-logs, where ng serve writes LynxLogger's output, to .gitignore",
|
|
22
|
+
"factory": "./migrations/dev-logs-gitignore/index"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|