ngx-devkit-builders 0.1.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2022 - 2023 Celtian
3
+ Copyright (c) 2022 - 2024 Celtian
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -13,52 +13,27 @@
13
13
 
14
14
  This package contains Architect builders used to build and test Angular applications and libraries.
15
15
 
16
- > ✓ _Angular 16 compatible_
16
+ > ✓ _Angular 17 compatible_
17
17
 
18
18
  ## Builders
19
19
 
20
- | Name | Description |
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
+ ## Compatibility
27
28
 
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
- ```
29
+ | Angular | ngx-app-version | Install |
30
+ | ------- | --------------- | ---------------------------- |
31
+ | >= 17 | 1.x | `yarn add ngx-app-version` |
32
+ | >= 16 | 0.x | `yarn add ngx-app-version@0` |
58
33
 
59
34
  ## License
60
35
 
61
- Copyright © 2022 - 2023 [Dominik Hladik](https://github.com/Celtian)
36
+ Copyright © 2022 - 2024 [Dominik Hladik](https://github.com/Celtian)
62
37
 
63
38
  All contents are licensed under the [MIT license].
64
39
 
package/builders.json CHANGED
@@ -1,5 +1,10 @@
1
1
  {
2
2
  "builders": {
3
+ "robots": {
4
+ "description": "Create simplified robots file",
5
+ "implementation": "./robots",
6
+ "schema": "./robots/schema.json"
7
+ },
3
8
  "version": {
4
9
  "description": "Create build information file",
5
10
  "implementation": "./version",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ngx-devkit-builders",
3
- "version": "0.1.0",
3
+ "version": "1.1.0",
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.1602.0",
16
- "@angular-devkit/core": "^16.2.0"
15
+ "@angular-devkit/architect": "^0.1700.8",
16
+ "@angular-devkit/core": "^17.0.8"
17
17
  },
18
18
  "devDependencies": {},
19
19
  "homepage": "https://github.com/Celtian/ngx-devkit-builders#readme",
@@ -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
+ }
@@ -30,7 +30,7 @@
30
30
  "verbose": {
31
31
  "description": "Extended logging output",
32
32
  "type": "boolean",
33
- "default": "false"
33
+ "default": false
34
34
  }
35
35
  }
36
36
  }