ngx-devkit-builders 1.1.0 → 1.2.1
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 +5 -4
- package/builders.json +5 -0
- package/copy-environment/index.js +54 -0
- package/copy-environment/schema.json +24 -0
- package/package.json +6 -4
- package/robots/index.js +8 -2
package/README.md
CHANGED
|
@@ -17,10 +17,11 @@ This package contains Architect builders used to build and test Angular applicat
|
|
|
17
17
|
|
|
18
18
|
## Builders
|
|
19
19
|
|
|
20
|
-
| Name
|
|
21
|
-
|
|
|
22
|
-
| [version](./src/version/README.md)
|
|
23
|
-
| [robots](./src/robots/README.md)
|
|
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 |
|
|
24
|
+
| [copy-environment](./src/copy-environment/README.md) | Copy environment file |
|
|
24
25
|
|
|
25
26
|
_More builders can be added in the future._
|
|
26
27
|
|
package/builders.json
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"builders": {
|
|
3
|
+
"copy-environment": {
|
|
4
|
+
"description": "Copy environment file",
|
|
5
|
+
"implementation": "./copy-environment",
|
|
6
|
+
"schema": "./copy-environment/schema.json"
|
|
7
|
+
},
|
|
3
8
|
"robots": {
|
|
4
9
|
"description": "Create simplified robots file",
|
|
5
10
|
"implementation": "./robots",
|
|
@@ -0,0 +1,54 @@
|
|
|
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_extra_1 = require("fs-extra");
|
|
6
|
+
async function copyFiles({ sourceFile, targetFile, overwrite }) {
|
|
7
|
+
return new Promise((resolve, reject) => {
|
|
8
|
+
(0, fs_extra_1.copy)(sourceFile, targetFile, { overwrite }, () => {
|
|
9
|
+
reject();
|
|
10
|
+
});
|
|
11
|
+
resolve();
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
exports.default = (0, architect_1.createBuilder)(async ({ verbose, source, target, overwrite }, ctx) => {
|
|
15
|
+
ctx.logger.info('🚧 Creating robots file…');
|
|
16
|
+
const projectMetadata = await ctx.getProjectMetadata(ctx.target.project);
|
|
17
|
+
if (projectMetadata.projectType !== 'application') {
|
|
18
|
+
ctx.logger.error('❌ Project must be type of application');
|
|
19
|
+
return {
|
|
20
|
+
success: false,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
if (ctx.target.configuration) {
|
|
24
|
+
ctx.logger.info(`Selected configuration "${ctx.target.configuration}"`);
|
|
25
|
+
}
|
|
26
|
+
const rootPath = (0, core_1.getSystemPath)((0, core_1.normalize)(ctx.workspaceRoot));
|
|
27
|
+
const environmentsFolder = `${rootPath}/${projectMetadata.sourceRoot}/environments`;
|
|
28
|
+
if (verbose)
|
|
29
|
+
ctx.logger.info(`Target folder is here "${environmentsFolder}"`);
|
|
30
|
+
const sourceFile = `${environmentsFolder}/${source}`;
|
|
31
|
+
const targetFile = `${environmentsFolder}/${target}`;
|
|
32
|
+
try {
|
|
33
|
+
await copyFiles({
|
|
34
|
+
sourceFile,
|
|
35
|
+
targetFile,
|
|
36
|
+
overwrite,
|
|
37
|
+
});
|
|
38
|
+
if (overwrite) {
|
|
39
|
+
ctx.logger.info(`✔️ Environment replaced in "${targetFile}"`);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
ctx.logger.info(`✔️ Environment replaced in "${targetFile}" if not exists`);
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
success: true,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
ctx.logger.error(`❌ Failed to replace file "${targetFile}"`);
|
|
50
|
+
return {
|
|
51
|
+
success: false,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"type": "object",
|
|
4
|
+
"properties": {
|
|
5
|
+
"source": {
|
|
6
|
+
"description": "Relative path to source file",
|
|
7
|
+
"type": "string"
|
|
8
|
+
},
|
|
9
|
+
"target": {
|
|
10
|
+
"description": "Relative path to target file",
|
|
11
|
+
"type": "string"
|
|
12
|
+
},
|
|
13
|
+
"overwrite": {
|
|
14
|
+
"description": "Overwrite target",
|
|
15
|
+
"type": "boolean",
|
|
16
|
+
"default": false
|
|
17
|
+
},
|
|
18
|
+
"verbose": {
|
|
19
|
+
"description": "Extended logging output",
|
|
20
|
+
"type": "boolean",
|
|
21
|
+
"default": false
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ngx-devkit-builders",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "Dominik Hladík",
|
|
6
6
|
"email": "dominik.hladik@seznam.cz",
|
|
@@ -12,8 +12,9 @@
|
|
|
12
12
|
"builders": "builders.json",
|
|
13
13
|
"scripts": {},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@angular-devkit/architect": "^0.
|
|
16
|
-
"@angular-devkit/core": "^17.
|
|
15
|
+
"@angular-devkit/architect": "^0.1701.3",
|
|
16
|
+
"@angular-devkit/core": "^17.1.3",
|
|
17
|
+
"fs-extra": "^11.2.0"
|
|
17
18
|
},
|
|
18
19
|
"devDependencies": {},
|
|
19
20
|
"homepage": "https://github.com/Celtian/ngx-devkit-builders#readme",
|
|
@@ -31,7 +32,8 @@
|
|
|
31
32
|
"url": "https://github.com/Celtian/ngx-devkit-builders/issues"
|
|
32
33
|
},
|
|
33
34
|
"engines": {
|
|
34
|
-
"node": ">=12"
|
|
35
|
+
"node": ">=12",
|
|
36
|
+
"npm": "please-use-yarn"
|
|
35
37
|
},
|
|
36
38
|
"publishConfig": {
|
|
37
39
|
"registry": "https://registry.npmjs.org"
|
package/robots/index.js
CHANGED
|
@@ -18,11 +18,17 @@ const createRobots = (options) => {
|
|
|
18
18
|
};
|
|
19
19
|
exports.default = (0, architect_1.createBuilder)(async ({ allow, sitemap, verbose }, ctx) => {
|
|
20
20
|
ctx.logger.info('🚧 Creating robots file…');
|
|
21
|
-
const
|
|
21
|
+
const projectMetadata = await ctx.getProjectMetadata(ctx.target.project);
|
|
22
|
+
if (projectMetadata.projectType !== 'application') {
|
|
23
|
+
ctx.logger.error('❌ Project must be type of application');
|
|
24
|
+
return {
|
|
25
|
+
success: false,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
22
28
|
if (ctx.target.configuration) {
|
|
23
29
|
ctx.logger.info(`Selected configuration "${ctx.target.configuration}"`);
|
|
24
30
|
}
|
|
25
|
-
const
|
|
31
|
+
const rootPath = (0, core_1.getSystemPath)((0, core_1.normalize)(ctx.workspaceRoot));
|
|
26
32
|
const targetFile = `${rootPath}/${projectMetadata.sourceRoot}/robots.txt`;
|
|
27
33
|
if (verbose === true)
|
|
28
34
|
ctx.logger.info(`Target file is here "${targetFile}"`);
|