ngx-devkit-builders 1.0.0 → 1.1.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/LICENSE +1 -1
- package/README.md +5 -37
- package/builders.json +5 -0
- package/package.json +1 -1
- package/robots/index.js +37 -0
- package/robots/schema.json +21 -0
- package/version/schema.json +1 -1
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -17,45 +17,13 @@ This package contains Architect builders used to build and test Angular applicat
|
|
|
17
17
|
|
|
18
18
|
## Builders
|
|
19
19
|
|
|
20
|
-
| Name
|
|
21
|
-
|
|
|
22
|
-
| version | Create build information file
|
|
20
|
+
| Name | Description |
|
|
21
|
+
| ---------------------------------- | --------------------------------- |
|
|
22
|
+
| [version](./src/version/README.md) | Create build information file |
|
|
23
|
+
| [robots](./src/robots/README.md) | Create simplified robots.txt file |
|
|
23
24
|
|
|
24
25
|
_More builders can be added in the future._
|
|
25
26
|
|
|
26
|
-
## Quick start
|
|
27
|
-
|
|
28
|
-
1. Go to angular.json
|
|
29
|
-
|
|
30
|
-
```json
|
|
31
|
-
{
|
|
32
|
-
...,
|
|
33
|
-
"projects": {
|
|
34
|
-
"your-project-name": { // project will be different
|
|
35
|
-
...,
|
|
36
|
-
"architect": {
|
|
37
|
-
...,
|
|
38
|
-
"version": { // name can be different if you want
|
|
39
|
-
"builder": "ngx-devkit-builders:version",
|
|
40
|
-
"options": { // not needed
|
|
41
|
-
"outputFile": "src/environments/version.ts", // or src/assets/version.json
|
|
42
|
-
"fields": ["version", "date", "author", "git"], // or custom selection
|
|
43
|
-
"lint": "eslint", // or "tslint"
|
|
44
|
-
"variable": "VERSION", // or whatever you want
|
|
45
|
-
"verbose": false // or true
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
2. Run command
|
|
54
|
-
|
|
55
|
-
```
|
|
56
|
-
ng run your-project-name:version
|
|
57
|
-
```
|
|
58
|
-
|
|
59
27
|
## Compatibility
|
|
60
28
|
|
|
61
29
|
| Angular | ngx-app-version | Install |
|
|
@@ -65,7 +33,7 @@ ng run your-project-name:version
|
|
|
65
33
|
|
|
66
34
|
## License
|
|
67
35
|
|
|
68
|
-
Copyright © 2022 -
|
|
36
|
+
Copyright © 2022 - 2024 [Dominik Hladik](https://github.com/Celtian)
|
|
69
37
|
|
|
70
38
|
All contents are licensed under the [MIT license].
|
|
71
39
|
|
package/builders.json
CHANGED
package/package.json
CHANGED
package/robots/index.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const architect_1 = require("@angular-devkit/architect");
|
|
4
|
+
const core_1 = require("@angular-devkit/core");
|
|
5
|
+
const fs_1 = require("fs");
|
|
6
|
+
const createRobots = (options) => {
|
|
7
|
+
const lines = ['User-agent: *'];
|
|
8
|
+
if (options.allow) {
|
|
9
|
+
lines.push('Allow: /');
|
|
10
|
+
if (options.sitemap) {
|
|
11
|
+
lines.push(`Sitemap: ${options.sitemap}`);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
lines.push('Disallow: /');
|
|
16
|
+
}
|
|
17
|
+
return lines.join('\n\n');
|
|
18
|
+
};
|
|
19
|
+
exports.default = (0, architect_1.createBuilder)(async ({ allow, sitemap, verbose }, ctx) => {
|
|
20
|
+
ctx.logger.info('🚧 Creating robots file…');
|
|
21
|
+
const rootPath = (0, core_1.getSystemPath)((0, core_1.normalize)(ctx.workspaceRoot));
|
|
22
|
+
if (ctx.target.configuration) {
|
|
23
|
+
ctx.logger.info(`Selected configuration "${ctx.target.configuration}"`);
|
|
24
|
+
}
|
|
25
|
+
const projectMetadata = await ctx.getProjectMetadata(ctx.target.project);
|
|
26
|
+
const targetFile = `${rootPath}/${projectMetadata.sourceRoot}/robots.txt`;
|
|
27
|
+
if (verbose === true)
|
|
28
|
+
ctx.logger.info(`Target file is here "${targetFile}"`);
|
|
29
|
+
(0, fs_1.writeFileSync)(targetFile, createRobots({
|
|
30
|
+
allow,
|
|
31
|
+
sitemap,
|
|
32
|
+
}), { encoding: 'utf-8' });
|
|
33
|
+
ctx.logger.info(`✔️ Robots file successfully created in ${targetFile}`);
|
|
34
|
+
return {
|
|
35
|
+
success: true,
|
|
36
|
+
};
|
|
37
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"type": "object",
|
|
4
|
+
"properties": {
|
|
5
|
+
"allow": {
|
|
6
|
+
"description": "Allow or disallow",
|
|
7
|
+
"type": "boolean",
|
|
8
|
+
"default": false
|
|
9
|
+
},
|
|
10
|
+
"sitemap": {
|
|
11
|
+
"description": "Sitemap.xml url",
|
|
12
|
+
"type": "string",
|
|
13
|
+
"default": ""
|
|
14
|
+
},
|
|
15
|
+
"verbose": {
|
|
16
|
+
"description": "Extended logging output",
|
|
17
|
+
"type": "boolean",
|
|
18
|
+
"default": false
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|