@smapiot/pilet-template-angular 1.0.12 → 1.0.13-beta.7987
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 +25 -11
- package/package.json +8 -3
- package/src/index.ts +47 -14
- package/templates/index.standalone.tsx.ejs +30 -0
- package/templates/menu.component.ts.ejs +3 -0
- package/templates/page.component.ts.ejs +3 -0
package/lib/index.js
CHANGED
|
@@ -1633,9 +1633,15 @@ var src_default = (0, import_template_utils.createPiletTemplateFactory)(root, (p
|
|
|
1633
1633
|
} else if (!isKnownVersion(args.ngVersion)) {
|
|
1634
1634
|
(0, import_template_utils.log)("warn", `Angular version ${args.ngVersion} is not known and therefore not yet officially supported. It might not work.`);
|
|
1635
1635
|
}
|
|
1636
|
+
if (args.ngVersion < 17) {
|
|
1637
|
+
args.ngStandalone = false;
|
|
1638
|
+
}
|
|
1639
|
+
if (typeof args.ngStandalone === "undefined") {
|
|
1640
|
+
args.standalone = args.ngVersion > 18;
|
|
1641
|
+
}
|
|
1636
1642
|
const ngVersion = `^${args.ngVersion}`;
|
|
1637
1643
|
const packageJson = args.standalone ? getStandalonePackageJson(details.cliVersion, ngVersion, args.ngVersion) : getStandardPackageJson(details.cliVersion, ngVersion, args.ngVersion);
|
|
1638
|
-
|
|
1644
|
+
const templates = [
|
|
1639
1645
|
{
|
|
1640
1646
|
languages: ["ts", "js"],
|
|
1641
1647
|
name: "package.json",
|
|
@@ -1652,21 +1658,11 @@ var src_default = (0, import_template_utils.createPiletTemplateFactory)(root, (p
|
|
|
1652
1658
|
name: "webpack.config.js",
|
|
1653
1659
|
target: "<root>/webpack.config.js"
|
|
1654
1660
|
},
|
|
1655
|
-
{
|
|
1656
|
-
languages: ["ts"],
|
|
1657
|
-
name: "index.tsx",
|
|
1658
|
-
target: "<src>/index.tsx"
|
|
1659
|
-
},
|
|
1660
1661
|
{
|
|
1661
1662
|
languages: ["js"],
|
|
1662
1663
|
name: "index.jsx",
|
|
1663
1664
|
target: "<src>/index.jsx"
|
|
1664
1665
|
},
|
|
1665
|
-
{
|
|
1666
|
-
languages: ["ts"],
|
|
1667
|
-
name: "app.module.ts",
|
|
1668
|
-
target: "<src>/app/app.module.ts"
|
|
1669
|
-
},
|
|
1670
1666
|
{
|
|
1671
1667
|
languages: ["ts"],
|
|
1672
1668
|
name: "page.component.html",
|
|
@@ -1698,6 +1694,24 @@ var src_default = (0, import_template_utils.createPiletTemplateFactory)(root, (p
|
|
|
1698
1694
|
target: "<root>/tsconfig.json"
|
|
1699
1695
|
}
|
|
1700
1696
|
];
|
|
1697
|
+
if (args.ngStandalone) {
|
|
1698
|
+
templates.push({
|
|
1699
|
+
languages: ["ts"],
|
|
1700
|
+
name: "index.standalone.tsx",
|
|
1701
|
+
target: "<src>/index.tsx"
|
|
1702
|
+
});
|
|
1703
|
+
} else {
|
|
1704
|
+
templates.push({
|
|
1705
|
+
languages: ["ts"],
|
|
1706
|
+
name: "index.tsx",
|
|
1707
|
+
target: "<src>/index.tsx"
|
|
1708
|
+
}, {
|
|
1709
|
+
languages: ["ts"],
|
|
1710
|
+
name: "app.module.ts",
|
|
1711
|
+
target: "<src>/app/app.module.ts"
|
|
1712
|
+
});
|
|
1713
|
+
}
|
|
1714
|
+
return templates;
|
|
1701
1715
|
});
|
|
1702
1716
|
module.exports = __toCommonJS(src_exports);
|
|
1703
1717
|
// Annotate the CommonJS export names for ESM import in node:
|
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.13-beta.7987",
|
|
4
4
|
"description": "Official scaffolding template for pilets: 'angular'.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"piral-cli",
|
|
@@ -22,6 +22,11 @@
|
|
|
22
22
|
"default": false,
|
|
23
23
|
"type": "boolean"
|
|
24
24
|
},
|
|
25
|
+
"ngStandalone": {
|
|
26
|
+
"description": "Defines if Angular should be used with standalone components (17+).",
|
|
27
|
+
"default": false,
|
|
28
|
+
"type": "boolean"
|
|
29
|
+
},
|
|
25
30
|
"ngVersion": {
|
|
26
31
|
"description": "Defines the (major) version of Angular to use in case of a standalone pilet.",
|
|
27
32
|
"default": 17,
|
|
@@ -54,7 +59,7 @@
|
|
|
54
59
|
"test": "echo \"Error: run tests from root\" && exit 1"
|
|
55
60
|
},
|
|
56
61
|
"devDependencies": {
|
|
57
|
-
"@smapiot/template-utils": "
|
|
62
|
+
"@smapiot/template-utils": "1.0.13-beta.7987"
|
|
58
63
|
},
|
|
59
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "3262fa4c2eb9271198fb9ac3c806c856009fefc5"
|
|
60
65
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
import { resolve } from 'path';
|
|
2
|
-
import { createPiletTemplateFactory, getPiralInstance, log } from '@smapiot/template-utils';
|
|
3
|
-
import {
|
|
2
|
+
import { createPiletTemplateFactory, getPiralInstance, log, PiletTemplateSource } from '@smapiot/template-utils';
|
|
3
|
+
import {
|
|
4
|
+
detectMode,
|
|
5
|
+
detectNgVersion,
|
|
6
|
+
getStandalonePackageJson,
|
|
7
|
+
getStandardPackageJson,
|
|
8
|
+
isKnownVersion,
|
|
9
|
+
} from './helpers';
|
|
4
10
|
|
|
5
11
|
const root = resolve(__dirname, '..');
|
|
6
12
|
|
|
7
13
|
interface AngularPiletArgs {
|
|
8
14
|
standalone: boolean;
|
|
9
15
|
ngVersion: number;
|
|
16
|
+
ngStandalone: boolean;
|
|
10
17
|
}
|
|
11
18
|
|
|
12
19
|
export default createPiletTemplateFactory<AngularPiletArgs>(root, (projectRoot, args, details) => {
|
|
@@ -26,7 +33,18 @@ export default createPiletTemplateFactory<AngularPiletArgs>(root, (projectRoot,
|
|
|
26
33
|
if (args.ngVersion < 9) {
|
|
27
34
|
log('warn', `Angular version ${args.ngVersion} is not officially supported. It might not work.`);
|
|
28
35
|
} else if (!isKnownVersion(args.ngVersion)) {
|
|
29
|
-
log(
|
|
36
|
+
log(
|
|
37
|
+
'warn',
|
|
38
|
+
`Angular version ${args.ngVersion} is not known and therefore not yet officially supported. It might not work.`,
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (args.ngVersion < 17) {
|
|
43
|
+
args.ngStandalone = false;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (typeof args.ngStandalone === 'undefined') {
|
|
47
|
+
args.standalone = args.ngVersion > 18;
|
|
30
48
|
}
|
|
31
49
|
|
|
32
50
|
const ngVersion = `^${args.ngVersion}`;
|
|
@@ -34,7 +52,7 @@ export default createPiletTemplateFactory<AngularPiletArgs>(root, (projectRoot,
|
|
|
34
52
|
? getStandalonePackageJson(details.cliVersion, ngVersion, args.ngVersion)
|
|
35
53
|
: getStandardPackageJson(details.cliVersion, ngVersion, args.ngVersion);
|
|
36
54
|
|
|
37
|
-
|
|
55
|
+
const templates: Array<PiletTemplateSource> = [
|
|
38
56
|
{
|
|
39
57
|
languages: ['ts', 'js'],
|
|
40
58
|
name: 'package.json',
|
|
@@ -51,21 +69,11 @@ export default createPiletTemplateFactory<AngularPiletArgs>(root, (projectRoot,
|
|
|
51
69
|
name: 'webpack.config.js',
|
|
52
70
|
target: '<root>/webpack.config.js',
|
|
53
71
|
},
|
|
54
|
-
{
|
|
55
|
-
languages: ['ts'],
|
|
56
|
-
name: 'index.tsx',
|
|
57
|
-
target: '<src>/index.tsx',
|
|
58
|
-
},
|
|
59
72
|
{
|
|
60
73
|
languages: ['js'],
|
|
61
74
|
name: 'index.jsx',
|
|
62
75
|
target: '<src>/index.jsx',
|
|
63
76
|
},
|
|
64
|
-
{
|
|
65
|
-
languages: ['ts'],
|
|
66
|
-
name: 'app.module.ts',
|
|
67
|
-
target: '<src>/app/app.module.ts',
|
|
68
|
-
},
|
|
69
77
|
{
|
|
70
78
|
languages: ['ts'],
|
|
71
79
|
name: 'page.component.html',
|
|
@@ -97,4 +105,29 @@ export default createPiletTemplateFactory<AngularPiletArgs>(root, (projectRoot,
|
|
|
97
105
|
target: '<root>/tsconfig.json',
|
|
98
106
|
},
|
|
99
107
|
];
|
|
108
|
+
|
|
109
|
+
if (args.ngStandalone) {
|
|
110
|
+
templates.push(
|
|
111
|
+
{
|
|
112
|
+
languages: ['ts'],
|
|
113
|
+
name: 'index.standalone.tsx',
|
|
114
|
+
target: '<src>/index.tsx',
|
|
115
|
+
},
|
|
116
|
+
);
|
|
117
|
+
} else {
|
|
118
|
+
templates.push(
|
|
119
|
+
{
|
|
120
|
+
languages: ['ts'],
|
|
121
|
+
name: 'index.tsx',
|
|
122
|
+
target: '<src>/index.tsx',
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
languages: ['ts'],
|
|
126
|
+
name: 'app.module.ts',
|
|
127
|
+
target: '<src>/app/app.module.ts',
|
|
128
|
+
},
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return templates;
|
|
100
133
|
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import 'core-js/proposals/reflect-metadata';
|
|
2
|
+
import { createConverter } from 'piral-ng/standalone';
|
|
3
|
+
import type { ApplicationConfig } from '@angular/core';
|
|
4
|
+
import type { PiletApi } from '<%- sourceName %>';
|
|
5
|
+
<% if (plugins.menu) { -%>
|
|
6
|
+
import { MenuComponent } from './app/menu.component';
|
|
7
|
+
<% } -%>
|
|
8
|
+
|
|
9
|
+
import { PageComponent } from './app/page.component';
|
|
10
|
+
|
|
11
|
+
const appConfig: ApplicationConfig = {
|
|
12
|
+
providers: [
|
|
13
|
+
provideRouter([
|
|
14
|
+
{
|
|
15
|
+
path: "sample",
|
|
16
|
+
component: AngularPage,
|
|
17
|
+
},
|
|
18
|
+
]),
|
|
19
|
+
],
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export function setup(app: PiletApi) {
|
|
23
|
+
const fromNg = createConverter(appConfig);
|
|
24
|
+
|
|
25
|
+
<% if (plugins.menu) { -%>
|
|
26
|
+
app.registerMenu(fromNg(MenuComponent));
|
|
27
|
+
<% } -%>
|
|
28
|
+
|
|
29
|
+
app.registerPage('/sample', fromNg(PageComponent));
|
|
30
|
+
}
|