@smapiot/pilet-template-angular 0.15.0-beta.4610 → 0.15.0-beta.4629
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/lib/index.js +77 -14
- package/package.json +3 -3
- package/src/helpers.ts +9 -10
- package/templates/app.module.ts.ejs +4 -4
- package/templates/index.jsx.ejs +0 -2
- package/templates/index.tsx.ejs +9 -9
- package/templates/page.component.ts.ejs +2 -2
package/lib/index.js
CHANGED
|
@@ -46,9 +46,73 @@ var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
|
46
46
|
// ../../packages/template-utils/lib/merge.js
|
|
47
47
|
var require_merge = __commonJS({
|
|
48
48
|
"../../packages/template-utils/lib/merge.js"(exports) {
|
|
49
|
+
"use strict";
|
|
50
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
|
+
exports.deepMerge = void 0;
|
|
52
|
+
function isMergeableObject(val) {
|
|
53
|
+
const nonNullObject = val && typeof val === "object";
|
|
54
|
+
return nonNullObject && Object.prototype.toString.call(val) !== "[object RegExp]" && Object.prototype.toString.call(val) !== "[object Date]";
|
|
55
|
+
}
|
|
56
|
+
function emptyTarget(val) {
|
|
57
|
+
return Array.isArray(val) ? [] : {};
|
|
58
|
+
}
|
|
59
|
+
function cloneIfNecessary(value) {
|
|
60
|
+
switch (typeof value) {
|
|
61
|
+
case "boolean":
|
|
62
|
+
case "number":
|
|
63
|
+
case "string":
|
|
64
|
+
case "symbol":
|
|
65
|
+
case "undefined":
|
|
66
|
+
return value;
|
|
67
|
+
}
|
|
68
|
+
return deepMerge(emptyTarget(value), value);
|
|
69
|
+
}
|
|
70
|
+
function defaultArrayMerge(target, source) {
|
|
71
|
+
const destination = target.slice();
|
|
72
|
+
source.forEach((e, i) => {
|
|
73
|
+
if (typeof destination[i] === "undefined") {
|
|
74
|
+
destination[i] = cloneIfNecessary(e);
|
|
75
|
+
} else if (isMergeableObject(e)) {
|
|
76
|
+
destination[i] = deepMerge(target[i], e);
|
|
77
|
+
} else if (target.indexOf(e) === -1) {
|
|
78
|
+
destination.push(cloneIfNecessary(e));
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
return destination;
|
|
82
|
+
}
|
|
83
|
+
function mergeObject(target, source) {
|
|
84
|
+
const destination = {};
|
|
85
|
+
if (isMergeableObject(target)) {
|
|
86
|
+
Object.keys(target).forEach((key) => {
|
|
87
|
+
destination[key] = cloneIfNecessary(target[key]);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
Object.keys(source).forEach((key) => {
|
|
91
|
+
if (!isMergeableObject(source[key]) || !target[key]) {
|
|
92
|
+
destination[key] = cloneIfNecessary(source[key]);
|
|
93
|
+
} else {
|
|
94
|
+
destination[key] = deepMerge(target[key], source[key]);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
return destination;
|
|
98
|
+
}
|
|
99
|
+
function deepMerge(target, source) {
|
|
100
|
+
if (Array.isArray(source)) {
|
|
101
|
+
return Array.isArray(target) ? defaultArrayMerge(target, source) : cloneIfNecessary(source);
|
|
102
|
+
}
|
|
103
|
+
return mergeObject(target, source);
|
|
104
|
+
}
|
|
105
|
+
exports.deepMerge = deepMerge;
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
// ../../packages/template-utils/lib/io.js
|
|
110
|
+
var require_io = __commonJS({
|
|
111
|
+
"../../packages/template-utils/lib/io.js"(exports) {
|
|
49
112
|
"use strict";
|
|
50
113
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
114
|
exports.mergeFiles = void 0;
|
|
115
|
+
var merge_1 = require_merge();
|
|
52
116
|
function mergeFiles(files) {
|
|
53
117
|
const result = {};
|
|
54
118
|
for (const file of files) {
|
|
@@ -62,7 +126,7 @@ var require_merge = __commonJS({
|
|
|
62
126
|
return Object.keys(result).map((path) => {
|
|
63
127
|
const items = result[path];
|
|
64
128
|
if (items.length !== 1 && path.endsWith("package.json")) {
|
|
65
|
-
const obj = items.map(({ content }) => JSON.parse(content.toString("utf8"))).reduce((p, c) =>
|
|
129
|
+
const obj = items.map(({ content }) => JSON.parse(content.toString("utf8"))).reduce((p, c) => (0, merge_1.deepMerge)(p, c), {});
|
|
66
130
|
const str = JSON.stringify(obj);
|
|
67
131
|
return {
|
|
68
132
|
path,
|
|
@@ -1175,7 +1239,7 @@ var require_factory = __commonJS({
|
|
|
1175
1239
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1176
1240
|
exports.createPiralTemplateFactory = exports.createPiletTemplateFactory = void 0;
|
|
1177
1241
|
var path_1 = require("path");
|
|
1178
|
-
var
|
|
1242
|
+
var io_1 = require_io();
|
|
1179
1243
|
var template_1 = require_template();
|
|
1180
1244
|
var parent_1 = require_parent();
|
|
1181
1245
|
var utils_1 = require_utils2();
|
|
@@ -1199,7 +1263,7 @@ var require_factory = __commonJS({
|
|
|
1199
1263
|
});
|
|
1200
1264
|
const defaultSource = (0, utils_1.getPackageJsonWithSource)(data.projectRoot, data.src, `index${data.extension}`);
|
|
1201
1265
|
const files = yield Promise.all([...sources, defaultSource].map((source) => (0, template_1.getFileFromTemplate)(sourceDir, source, data)));
|
|
1202
|
-
return (0,
|
|
1266
|
+
return (0, io_1.mergeFiles)(files);
|
|
1203
1267
|
});
|
|
1204
1268
|
}
|
|
1205
1269
|
exports.createPiletTemplateFactory = createPiletTemplateFactory2;
|
|
@@ -1224,7 +1288,7 @@ var require_factory = __commonJS({
|
|
|
1224
1288
|
mocks
|
|
1225
1289
|
});
|
|
1226
1290
|
const files = yield Promise.all(sources.map((source) => (0, template_1.getFileFromTemplate)(sourceDir, source, data)));
|
|
1227
|
-
return (0,
|
|
1291
|
+
return (0, io_1.mergeFiles)(files);
|
|
1228
1292
|
});
|
|
1229
1293
|
}
|
|
1230
1294
|
exports.createPiralTemplateFactory = createPiralTemplateFactory;
|
|
@@ -1301,20 +1365,18 @@ function getStandalonePackageJson(cliVersion, ngVersion) {
|
|
|
1301
1365
|
return {
|
|
1302
1366
|
importmap: {
|
|
1303
1367
|
imports: {
|
|
1304
|
-
"@angular/animations": "
|
|
1305
|
-
"@angular/
|
|
1306
|
-
"@angular/
|
|
1307
|
-
"@angular/
|
|
1308
|
-
"@angular/
|
|
1309
|
-
"@angular/
|
|
1310
|
-
"@angular/platform-browser": "
|
|
1311
|
-
"@angular/
|
|
1312
|
-
"@angular/router": "."
|
|
1368
|
+
"@angular/animations": "@angular/animations",
|
|
1369
|
+
"@angular/common": "@angular/common",
|
|
1370
|
+
"@angular/compiler": "@angular/compiler",
|
|
1371
|
+
"@angular/core": "@angular/core",
|
|
1372
|
+
"@angular/forms": "@angular/forms",
|
|
1373
|
+
"@angular/platform-browser": "@angular/platform-browser",
|
|
1374
|
+
"@angular/platform-browser-dynamic": "@angular/platform-browser-dynamic",
|
|
1375
|
+
"@angular/router": "@angular/router"
|
|
1313
1376
|
}
|
|
1314
1377
|
},
|
|
1315
1378
|
dependencies: {
|
|
1316
1379
|
"@angular/animations": ngVersion,
|
|
1317
|
-
"@angular/cli": ngVersion,
|
|
1318
1380
|
"@angular/common": ngVersion,
|
|
1319
1381
|
"@angular/compiler": ngVersion,
|
|
1320
1382
|
"@angular/core": ngVersion,
|
|
@@ -1328,6 +1390,7 @@ function getStandalonePackageJson(cliVersion, ngVersion) {
|
|
|
1328
1390
|
},
|
|
1329
1391
|
devDependencies: {
|
|
1330
1392
|
"@angular/compiler-cli": ngVersion,
|
|
1393
|
+
"@angular/cli": ngVersion,
|
|
1331
1394
|
"@ngtools/webpack": ngVersion,
|
|
1332
1395
|
"copy-webpack-plugin": "^10",
|
|
1333
1396
|
"html-loader": "^3",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smapiot/pilet-template-angular",
|
|
3
|
-
"version": "0.15.0-beta.
|
|
3
|
+
"version": "0.15.0-beta.4629",
|
|
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": "0.15.0-beta.
|
|
57
|
+
"@smapiot/template-utils": "0.15.0-beta.4629"
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "9f8126295daf838dfe133de6ee0a173110c36527"
|
|
60
60
|
}
|
package/src/helpers.ts
CHANGED
|
@@ -27,20 +27,18 @@ export function getStandalonePackageJson(cliVersion: string, ngVersion: string)
|
|
|
27
27
|
return {
|
|
28
28
|
importmap: {
|
|
29
29
|
imports: {
|
|
30
|
-
'@angular/animations': '
|
|
31
|
-
'@angular/
|
|
32
|
-
'@angular/
|
|
33
|
-
'@angular/
|
|
34
|
-
'@angular/
|
|
35
|
-
'@angular/
|
|
36
|
-
'@angular/platform-browser': '
|
|
37
|
-
'@angular/
|
|
38
|
-
'@angular/router': '.',
|
|
30
|
+
'@angular/animations': '@angular/animations',
|
|
31
|
+
'@angular/common': '@angular/common',
|
|
32
|
+
'@angular/compiler': '@angular/compiler',
|
|
33
|
+
'@angular/core': '@angular/core',
|
|
34
|
+
'@angular/forms': '@angular/forms',
|
|
35
|
+
'@angular/platform-browser': '@angular/platform-browser',
|
|
36
|
+
'@angular/platform-browser-dynamic': '@angular/platform-browser-dynamic',
|
|
37
|
+
'@angular/router': '@angular/router',
|
|
39
38
|
},
|
|
40
39
|
},
|
|
41
40
|
dependencies: {
|
|
42
41
|
'@angular/animations': ngVersion,
|
|
43
|
-
'@angular/cli': ngVersion,
|
|
44
42
|
'@angular/common': ngVersion,
|
|
45
43
|
'@angular/compiler': ngVersion,
|
|
46
44
|
'@angular/core': ngVersion,
|
|
@@ -54,6 +52,7 @@ export function getStandalonePackageJson(cliVersion: string, ngVersion: string)
|
|
|
54
52
|
},
|
|
55
53
|
devDependencies: {
|
|
56
54
|
'@angular/compiler-cli': ngVersion,
|
|
55
|
+
'@angular/cli': ngVersion,
|
|
57
56
|
'@ngtools/webpack': ngVersion,
|
|
58
57
|
'copy-webpack-plugin': '^10',
|
|
59
58
|
'html-loader': '^3',
|
|
@@ -5,9 +5,9 @@ import { SharedModule } from 'piral-ng/common';
|
|
|
5
5
|
import { PageComponent } from './page.component';
|
|
6
6
|
|
|
7
7
|
@NgModule({
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
bootstrap: [PageComponent],
|
|
9
|
+
declarations: [PageComponent],
|
|
10
|
+
exports: [PageComponent],
|
|
11
|
+
imports: [BrowserModule, SharedModule]
|
|
12
12
|
})
|
|
13
13
|
export class AppModule {}
|
package/templates/index.jsx.ejs
CHANGED
package/templates/index.tsx.ejs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
1
|
<% if (standalone) { -%>
|
|
2
|
+
import '@angular/compiler';
|
|
3
3
|
import { defineNgModule, fromNg } from 'piral-ng/convert';
|
|
4
4
|
<% } -%>
|
|
5
5
|
import { AppModule } from './app/app.module';
|
|
@@ -8,18 +8,18 @@ import type { PiletApi } from '<%- sourceName %>';
|
|
|
8
8
|
|
|
9
9
|
export function setup(app: PiletApi) {
|
|
10
10
|
<% if (standalone) { -%>
|
|
11
|
-
|
|
11
|
+
defineNgModule(AppModule, {
|
|
12
12
|
// remove the following if you actually want to enable zone.js
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
ngZone: 'noop',
|
|
14
|
+
});
|
|
15
15
|
|
|
16
|
-
app.registerPage('/sample',
|
|
16
|
+
app.registerPage('/sample', fromNg(PageComponent));
|
|
17
17
|
<% } else { -%>
|
|
18
|
-
|
|
18
|
+
app.defineNgModule(AppModule, {
|
|
19
19
|
// remove the following if you actually want to enable zone.js
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
ngZone: 'noop',
|
|
21
|
+
});
|
|
22
22
|
|
|
23
|
-
app.registerPage('/sample', fromNg(PageComponent));
|
|
23
|
+
app.registerPage('/sample', app.fromNg(PageComponent));
|
|
24
24
|
<% } -%>
|
|
25
25
|
}
|