@smapiot/pilet-template-angular 1.0.2 → 1.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 +1 -1
- package/lib/index.js +21 -10
- package/package.json +3 -3
- package/src/helpers.ts +14 -8
- package/src/index.ts +8 -2
package/README.md
CHANGED
|
@@ -24,7 +24,7 @@ npm init pilet -- --source <app-shell> --template angular <other-options>
|
|
|
24
24
|
The following variables are available when scaffolding. They can be applied via the CLI flags, e.g.,
|
|
25
25
|
|
|
26
26
|
```sh
|
|
27
|
-
pilet new <app-shell> --template angular --vars.standalone true --vars.ngVersion
|
|
27
|
+
pilet new <app-shell> --template angular --vars.standalone true --vars.ngVersion 16
|
|
28
28
|
```
|
|
29
29
|
|
|
30
30
|
For this template we have:
|
package/lib/index.js
CHANGED
|
@@ -151,7 +151,7 @@ var require_log = __commonJS({
|
|
|
151
151
|
logLevel = level;
|
|
152
152
|
}
|
|
153
153
|
exports.setLogLevel = setLogLevel;
|
|
154
|
-
function
|
|
154
|
+
function log2(level, message) {
|
|
155
155
|
if (level === "error") {
|
|
156
156
|
if (logLevel !== "disabled") {
|
|
157
157
|
console.error(`[template] ${message}`);
|
|
@@ -170,7 +170,7 @@ var require_log = __commonJS({
|
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
|
-
exports.log =
|
|
173
|
+
exports.log = log2;
|
|
174
174
|
}
|
|
175
175
|
});
|
|
176
176
|
|
|
@@ -1348,6 +1348,7 @@ var require_lib = __commonJS({
|
|
|
1348
1348
|
};
|
|
1349
1349
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1350
1350
|
__exportStar(require_factory(), exports);
|
|
1351
|
+
__exportStar(require_log(), exports);
|
|
1351
1352
|
__exportStar(require_template(), exports);
|
|
1352
1353
|
__exportStar(require_types(), exports);
|
|
1353
1354
|
__exportStar(require_utils2(), exports);
|
|
@@ -1425,25 +1426,29 @@ function detectNgVersion(piralInstance) {
|
|
|
1425
1426
|
const dependencies = ((_a = piralInstance == null ? void 0 : piralInstance.details) == null ? void 0 : _a.dependencies) || {};
|
|
1426
1427
|
const devDependencies = ((_b = piralInstance == null ? void 0 : piralInstance.details) == null ? void 0 : _b.devDependencies) || {};
|
|
1427
1428
|
const allDependencies = __spreadValues(__spreadValues({}, devDependencies), dependencies);
|
|
1428
|
-
const version = allDependencies["@angular/core"] || "
|
|
1429
|
+
const version = allDependencies["@angular/core"] || "16.0.0";
|
|
1429
1430
|
if (typeof version === "string") {
|
|
1430
1431
|
const result = /\d+/.exec(version);
|
|
1431
1432
|
if (result) {
|
|
1432
1433
|
return +result[0];
|
|
1433
1434
|
}
|
|
1434
1435
|
}
|
|
1435
|
-
return
|
|
1436
|
+
return 16;
|
|
1437
|
+
}
|
|
1438
|
+
function isKnownVersion(majorNgVersion) {
|
|
1439
|
+
return typeof zoneVersions[majorNgVersion] !== "undefined";
|
|
1436
1440
|
}
|
|
1437
1441
|
function getStandalonePackageJson(cliVersion, ngVersion, majorNgVersion) {
|
|
1438
1442
|
return {
|
|
1439
1443
|
importmap: {
|
|
1440
1444
|
imports: {
|
|
1441
|
-
"@angular/common": "
|
|
1442
|
-
"@angular/compiler": "
|
|
1443
|
-
"@angular/core": "
|
|
1444
|
-
"@angular/platform-browser": "
|
|
1445
|
-
"@angular/platform-browser-dynamic": "
|
|
1446
|
-
"@angular/router": "
|
|
1445
|
+
"@angular/common": "",
|
|
1446
|
+
"@angular/compiler": "",
|
|
1447
|
+
"@angular/core": "",
|
|
1448
|
+
"@angular/platform-browser": "",
|
|
1449
|
+
"@angular/platform-browser-dynamic": "",
|
|
1450
|
+
"@angular/router": "",
|
|
1451
|
+
"piral-ng-common": ""
|
|
1447
1452
|
}
|
|
1448
1453
|
},
|
|
1449
1454
|
dependencies: {
|
|
@@ -1454,6 +1459,7 @@ function getStandalonePackageJson(cliVersion, ngVersion, majorNgVersion) {
|
|
|
1454
1459
|
"@angular/platform-browser-dynamic": ngVersion,
|
|
1455
1460
|
"@angular/router": ngVersion,
|
|
1456
1461
|
"piral-ng": cliVersion,
|
|
1462
|
+
"piral-ng-common": ngVersion,
|
|
1457
1463
|
"core-js": "^3.19.0",
|
|
1458
1464
|
rxjs: rxjsVersions[majorNgVersion] || "^7.4",
|
|
1459
1465
|
"zone.js": zoneVersions[majorNgVersion] || "^0.13"
|
|
@@ -1496,6 +1502,11 @@ var src_default = (0, import_template_utils.createPiletTemplateFactory)(root, (p
|
|
|
1496
1502
|
} else if (args.ngVersion !== detectNgVersion(piralInstance)) {
|
|
1497
1503
|
args.standalone = true;
|
|
1498
1504
|
}
|
|
1505
|
+
if (args.ngVersion < 9) {
|
|
1506
|
+
(0, import_template_utils.log)("warn", `Angular version ${args.ngVersion} is not officially supported. It might not work.`);
|
|
1507
|
+
} else if (!isKnownVersion(args.ngVersion)) {
|
|
1508
|
+
(0, import_template_utils.log)("warn", `Angular version ${args.ngVersion} is not known and therefore not yet officially supported. It might not work.`);
|
|
1509
|
+
}
|
|
1499
1510
|
const ngVersion = `^${args.ngVersion}`;
|
|
1500
1511
|
const packageJson = args.standalone ? getStandalonePackageJson(details.cliVersion, ngVersion, args.ngVersion) : getStandardPackageJson(details.cliVersion, ngVersion, args.ngVersion);
|
|
1501
1512
|
return [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smapiot/pilet-template-angular",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "Official scaffolding template for pilets: 'angular'.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"piral-cli",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"test": "echo \"Error: run tests from root\" && exit 1"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@smapiot/template-utils": "^1.0.
|
|
57
|
+
"@smapiot/template-utils": "^1.0.4"
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "766d11d13233d2e7adf584a2c9ba85a11f5691fb"
|
|
60
60
|
}
|
package/src/helpers.ts
CHANGED
|
@@ -11,7 +11,7 @@ export function detectNgVersion(piralInstance: { details: any }) {
|
|
|
11
11
|
const dependencies = piralInstance?.details?.dependencies || {};
|
|
12
12
|
const devDependencies = piralInstance?.details?.devDependencies || {};
|
|
13
13
|
const allDependencies = { ...devDependencies, ...dependencies };
|
|
14
|
-
const version = allDependencies['@angular/core'] || '
|
|
14
|
+
const version = allDependencies['@angular/core'] || '16.0.0';
|
|
15
15
|
|
|
16
16
|
if (typeof version === 'string') {
|
|
17
17
|
const result = /\d+/.exec(version);
|
|
@@ -22,19 +22,24 @@ export function detectNgVersion(piralInstance: { details: any }) {
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
return
|
|
25
|
+
return 16;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function isKnownVersion(majorNgVersion: number) {
|
|
29
|
+
return typeof zoneVersions[majorNgVersion] !== 'undefined';
|
|
26
30
|
}
|
|
27
31
|
|
|
28
32
|
export function getStandalonePackageJson(cliVersion: string, ngVersion: string, majorNgVersion: number) {
|
|
29
33
|
return {
|
|
30
34
|
importmap: {
|
|
31
35
|
imports: {
|
|
32
|
-
'@angular/common': '
|
|
33
|
-
'@angular/compiler': '
|
|
34
|
-
'@angular/core': '
|
|
35
|
-
'@angular/platform-browser': '
|
|
36
|
-
'@angular/platform-browser-dynamic': '
|
|
37
|
-
'@angular/router': '
|
|
36
|
+
'@angular/common': '',
|
|
37
|
+
'@angular/compiler': '',
|
|
38
|
+
'@angular/core': '',
|
|
39
|
+
'@angular/platform-browser': '',
|
|
40
|
+
'@angular/platform-browser-dynamic': '',
|
|
41
|
+
'@angular/router': '',
|
|
42
|
+
'piral-ng-common': '',
|
|
38
43
|
},
|
|
39
44
|
},
|
|
40
45
|
dependencies: {
|
|
@@ -45,6 +50,7 @@ export function getStandalonePackageJson(cliVersion: string, ngVersion: string,
|
|
|
45
50
|
'@angular/platform-browser-dynamic': ngVersion,
|
|
46
51
|
'@angular/router': ngVersion,
|
|
47
52
|
'piral-ng': cliVersion,
|
|
53
|
+
'piral-ng-common': ngVersion,
|
|
48
54
|
'core-js': '^3.19.0',
|
|
49
55
|
rxjs: rxjsVersions[majorNgVersion] || '^7.4',
|
|
50
56
|
'zone.js': zoneVersions[majorNgVersion] || '^0.13',
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { resolve } from 'path';
|
|
2
|
-
import { createPiletTemplateFactory, getPiralInstance } from '@smapiot/template-utils';
|
|
3
|
-
import { detectMode, detectNgVersion, getStandalonePackageJson, getStandardPackageJson } from './helpers';
|
|
2
|
+
import { createPiletTemplateFactory, getPiralInstance, log } from '@smapiot/template-utils';
|
|
3
|
+
import { detectMode, detectNgVersion, getStandalonePackageJson, getStandardPackageJson, isKnownVersion } from './helpers';
|
|
4
4
|
|
|
5
5
|
const root = resolve(__dirname, '..');
|
|
6
6
|
|
|
@@ -23,6 +23,12 @@ export default createPiletTemplateFactory<AngularPiletArgs>(root, (projectRoot,
|
|
|
23
23
|
args.standalone = true;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
if (args.ngVersion < 9) {
|
|
27
|
+
log('warn', `Angular version ${args.ngVersion} is not officially supported. It might not work.`);
|
|
28
|
+
} else if (!isKnownVersion(args.ngVersion)) {
|
|
29
|
+
log('warn', `Angular version ${args.ngVersion} is not known and therefore not yet officially supported. It might not work.`);
|
|
30
|
+
}
|
|
31
|
+
|
|
26
32
|
const ngVersion = `^${args.ngVersion}`;
|
|
27
33
|
const packageJson = args.standalone
|
|
28
34
|
? getStandalonePackageJson(details.cliVersion, ngVersion, args.ngVersion)
|