ngx-devkit-builders 0.0.2 → 0.0.4
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 -2
- package/package.json +3 -3
- package/version/index.js +8 -3
- package/version/schema.json +5 -0
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<p align="center">
|
|
2
2
|
<a href="https://github.com/Celtian/ngx-devkit-builders" target="blank"><img src="assets/logo.svg?sanitize=true" alt="" width="120"></a>
|
|
3
|
-
<h1 align="center">
|
|
3
|
+
<h1 align="center">NgxDevkitBuilders</h1>
|
|
4
4
|
</p>
|
|
5
5
|
|
|
6
6
|
[](https://badge.fury.io/js/ngx-devkit-builders)
|
|
@@ -40,7 +40,8 @@ _More builders can be added in the future._
|
|
|
40
40
|
"options": { // not needed
|
|
41
41
|
"outputFile": "src/environments/version.ts", // or src/assets/version.json
|
|
42
42
|
"fields": ["version", "date", "author", "git"], // or custom selection
|
|
43
|
-
"lint": "eslint" // or "tslint"
|
|
43
|
+
"lint": "eslint", // or "tslint"
|
|
44
|
+
"variable": "VERSION" // or whatever you want
|
|
44
45
|
}
|
|
45
46
|
}
|
|
46
47
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ngx-devkit-builders",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "Dominik Hladík",
|
|
6
6
|
"email": "dominik.hladik@seznam.cz",
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
"builders": "builders.json",
|
|
13
13
|
"scripts": {},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@angular-devkit/architect": "^0.1500.
|
|
16
|
-
"@angular-devkit/core": "^15.0.
|
|
15
|
+
"@angular-devkit/architect": "^0.1500.4",
|
|
16
|
+
"@angular-devkit/core": "^15.0.4"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {},
|
|
19
19
|
"homepage": "https://github.com/Celtian/ngx-devkit-builders#readme",
|
package/version/index.js
CHANGED
|
@@ -3,12 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const architect_1 = require("@angular-devkit/architect");
|
|
4
4
|
const core_1 = require("@angular-devkit/core");
|
|
5
5
|
const fs_1 = require("fs");
|
|
6
|
-
exports.default = (0, architect_1.createBuilder)(({ outputFile, fields, lint }, ctx) => {
|
|
7
|
-
ctx.logger.info('Creating version information file');
|
|
6
|
+
exports.default = (0, architect_1.createBuilder)(({ outputFile, fields, lint, variable }, ctx) => {
|
|
7
|
+
ctx.logger.info('🚧 Creating version information file…');
|
|
8
|
+
let targetFile = '';
|
|
8
9
|
try {
|
|
9
10
|
const rootPath = (0, core_1.getSystemPath)((0, core_1.normalize)(ctx.workspaceRoot));
|
|
10
11
|
const encoding = 'utf-8';
|
|
11
12
|
const fileToPatch = `${rootPath}/${outputFile}`;
|
|
13
|
+
targetFile = fileToPatch;
|
|
12
14
|
const packageJsonContent = (0, fs_1.readFileSync)(`${rootPath}/package.json`, encoding);
|
|
13
15
|
let head = (0, fs_1.readFileSync)(`${rootPath}/.git/HEAD`, encoding).toString().trim();
|
|
14
16
|
if (head.split(':').length > 1) {
|
|
@@ -29,7 +31,7 @@ exports.default = (0, architect_1.createBuilder)(({ outputFile, fields, lint },
|
|
|
29
31
|
if (format === 'ts') {
|
|
30
32
|
(0, fs_1.writeFileSync)(fileToPatch, `// IMPORTANT: THIS FILE IS AUTO GENERATED!
|
|
31
33
|
/* ${lint === 'tslint' ? 'tslint:disable' : 'eslint-disable'} */
|
|
32
|
-
export const
|
|
34
|
+
export const ${variable} = ${json};
|
|
33
35
|
/* ${lint === 'tslint' ? 'tslint:enable' : 'eslint-enable'} */
|
|
34
36
|
`, { encoding: 'utf-8' });
|
|
35
37
|
}
|
|
@@ -38,10 +40,13 @@ export const VERSION = ${json};
|
|
|
38
40
|
}
|
|
39
41
|
}
|
|
40
42
|
catch (error) {
|
|
43
|
+
ctx.logger.info('❌ Creating version information file failed');
|
|
44
|
+
ctx.logger.error(JSON.stringify(error, null, 2));
|
|
41
45
|
return {
|
|
42
46
|
success: false
|
|
43
47
|
};
|
|
44
48
|
}
|
|
49
|
+
ctx.logger.info(`✔️ Version information file successfully created in ${targetFile}`);
|
|
45
50
|
return {
|
|
46
51
|
success: true
|
|
47
52
|
};
|
package/version/schema.json
CHANGED