@smapiot/pilet-template-angular 1.0.6-beta.6234 → 1.0.7-beta.6240

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.
Files changed (2) hide show
  1. package/lib/index.js +167 -141
  2. package/package.json +3 -3
package/lib/index.js CHANGED
@@ -43,6 +43,167 @@ var __toCommonJS = /* @__PURE__ */ ((cache) => {
43
43
  };
44
44
  })(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
45
45
 
46
+ // ../../packages/template-utils/lib/log.js
47
+ var require_log = __commonJS({
48
+ "../../packages/template-utils/lib/log.js"(exports) {
49
+ "use strict";
50
+ Object.defineProperty(exports, "__esModule", { value: true });
51
+ exports.log = exports.setLogLevel = void 0;
52
+ var logLevel = "warn";
53
+ function setLogLevel(level) {
54
+ logLevel = level;
55
+ }
56
+ exports.setLogLevel = setLogLevel;
57
+ function log2(level, message) {
58
+ if (level === "error") {
59
+ if (logLevel !== "disabled") {
60
+ console.error(`[template] ${message}`);
61
+ }
62
+ } else if (level === "warn") {
63
+ if (logLevel !== "error" && logLevel !== "disabled") {
64
+ console.warn(`[template] ${message}`);
65
+ }
66
+ } else if (level === "info") {
67
+ if (logLevel === "verbose" || logLevel === "info") {
68
+ console.info(`[template] ${message}`);
69
+ }
70
+ } else if (level === "verbose") {
71
+ if (logLevel === "verbose") {
72
+ console.log(`[template] ${message}`);
73
+ }
74
+ }
75
+ }
76
+ exports.log = log2;
77
+ }
78
+ });
79
+
80
+ // ../../packages/template-utils/lib/utils.js
81
+ var require_utils = __commonJS({
82
+ "../../packages/template-utils/lib/utils.js"(exports) {
83
+ "use strict";
84
+ Object.defineProperty(exports, "__esModule", { value: true });
85
+ exports.getLanguageExtension = exports.getPlugins = exports.getPiralInstance = exports.getProjectJson = exports.getPackageJsonWithSource = exports.makeRelative = void 0;
86
+ var path_1 = require("path");
87
+ var fs_1 = require("fs");
88
+ var log_1 = require_log();
89
+ function makeRelative(path, root2) {
90
+ const relPath = (0, path_1.isAbsolute)(path) ? (0, path_1.relative)(root2, path) : path;
91
+ return relPath.split(path_1.sep).join(path_1.posix.sep);
92
+ }
93
+ exports.makeRelative = makeRelative;
94
+ function getPackageJsonWithSource(root2, targetDir, fileName) {
95
+ const path = makeRelative(path_1.posix.join(targetDir, fileName), root2);
96
+ (0, log_1.log)("verbose", `Adding "source" to package.json: "${path}"`);
97
+ return {
98
+ languages: ["ts", "js"],
99
+ name: "package.json",
100
+ content: JSON.stringify({ source: path }),
101
+ target: "<root>/package.json"
102
+ };
103
+ }
104
+ exports.getPackageJsonWithSource = getPackageJsonWithSource;
105
+ function getProjectJson(root2) {
106
+ try {
107
+ return require(`${root2}/package.json`);
108
+ } catch (ex) {
109
+ (0, log_1.log)("error", `Error when reading the "package.json": ${ex}`);
110
+ }
111
+ return void 0;
112
+ }
113
+ exports.getProjectJson = getProjectJson;
114
+ function getPiralInstance2(root2, sourceName) {
115
+ try {
116
+ const packageJsonPath = require.resolve(`${sourceName}/package.json`, {
117
+ paths: [root2]
118
+ });
119
+ (0, log_1.log)("verbose", `Found package JSON in "${packageJsonPath}"`);
120
+ const sourcePath = (0, path_1.dirname)(packageJsonPath);
121
+ const details = require(packageJsonPath);
122
+ const types = details.types || details.typings;
123
+ (0, log_1.log)("verbose", `Looking for types in "${types}"`);
124
+ const typingsPath = types !== void 0 ? (0, path_1.resolve)(sourcePath, types) : void 0;
125
+ const app = details.app;
126
+ (0, log_1.log)("verbose", `Looking for types in "${app}"`);
127
+ const appPath = app !== void 0 ? (0, path_1.resolve)(sourcePath, app) : void 0;
128
+ return {
129
+ sourceName,
130
+ sourcePath,
131
+ details,
132
+ appPath,
133
+ typingsPath
134
+ };
135
+ } catch (ex) {
136
+ (0, log_1.log)("error", `Error when getting Piral instance: ${ex}`);
137
+ }
138
+ return void 0;
139
+ }
140
+ exports.getPiralInstance = getPiralInstance2;
141
+ function getPlugins(root2, sourceName) {
142
+ const plugins = {};
143
+ (0, log_1.log)("verbose", `Getting the plugins of "${sourceName}/package.json" ...`);
144
+ const piralInstance = getPiralInstance2(root2, sourceName);
145
+ const typingsPath = piralInstance === null || piralInstance === void 0 ? void 0 : piralInstance.typingsPath;
146
+ if (typingsPath) {
147
+ (0, log_1.log)("verbose", `Reading file in "${typingsPath}"`);
148
+ const typing = (0, fs_1.readFileSync)(typingsPath, "utf8");
149
+ const match = /export interface PiletCustomApi extends (.*?) \{/g.exec(typing);
150
+ if (!match) {
151
+ (0, log_1.log)("verbose", `No Piral instance plugins have been found`);
152
+ return [];
153
+ }
154
+ const apis = match[1].split(", ");
155
+ (0, log_1.log)("verbose", `Found Piral instance plugins "${match[1]}"`);
156
+ for (const api of apis) {
157
+ const pluginMatch = /^Pilet(.*)Api$/.exec(api);
158
+ if (pluginMatch) {
159
+ const name = pluginMatch[1].toLowerCase();
160
+ plugins[name] = true;
161
+ } else {
162
+ (0, log_1.log)("warn", `Could not find plugin for Pilet API "${api}"`);
163
+ }
164
+ }
165
+ }
166
+ return plugins;
167
+ }
168
+ exports.getPlugins = getPlugins;
169
+ function getLanguageExtension(language, isJsx = true) {
170
+ switch (language) {
171
+ case "js":
172
+ return isJsx ? ".jsx" : ".js";
173
+ case "ts":
174
+ default:
175
+ return isJsx ? ".tsx" : ".ts";
176
+ }
177
+ }
178
+ exports.getLanguageExtension = getLanguageExtension;
179
+ }
180
+ });
181
+
182
+ // ../../packages/template-utils/lib/bundler.js
183
+ var require_bundler = __commonJS({
184
+ "../../packages/template-utils/lib/bundler.js"(exports) {
185
+ "use strict";
186
+ Object.defineProperty(exports, "__esModule", { value: true });
187
+ exports.detectBundler = void 0;
188
+ var utils_1 = require_utils();
189
+ function detectBundler(root2) {
190
+ const projectJson = (0, utils_1.getProjectJson)(root2);
191
+ const devDependencies = projectJson === null || projectJson === void 0 ? void 0 : projectJson.devDependencies;
192
+ if (projectJson) {
193
+ const bundlers = ["esbuild", "webpack5", "webpack", "vite", "parcel2", "parcel", "bun", "rspack", "rollup"];
194
+ for (const bundler of bundlers) {
195
+ const dependencyName = `piral-cli-${bundler}`;
196
+ if (dependencyName in devDependencies) {
197
+ return bundler;
198
+ }
199
+ }
200
+ }
201
+ return "xbuild";
202
+ }
203
+ exports.detectBundler = detectBundler;
204
+ }
205
+ });
206
+
46
207
  // ../../packages/template-utils/lib/merge.js
47
208
  var require_merge = __commonJS({
48
209
  "../../packages/template-utils/lib/merge.js"(exports) {
@@ -140,40 +301,6 @@ var require_io = __commonJS({
140
301
  }
141
302
  });
142
303
 
143
- // ../../packages/template-utils/lib/log.js
144
- var require_log = __commonJS({
145
- "../../packages/template-utils/lib/log.js"(exports) {
146
- "use strict";
147
- Object.defineProperty(exports, "__esModule", { value: true });
148
- exports.log = exports.setLogLevel = void 0;
149
- var logLevel = "warn";
150
- function setLogLevel(level) {
151
- logLevel = level;
152
- }
153
- exports.setLogLevel = setLogLevel;
154
- function log2(level, message) {
155
- if (level === "error") {
156
- if (logLevel !== "disabled") {
157
- console.error(`[template] ${message}`);
158
- }
159
- } else if (level === "warn") {
160
- if (logLevel !== "error" && logLevel !== "disabled") {
161
- console.warn(`[template] ${message}`);
162
- }
163
- } else if (level === "info") {
164
- if (logLevel === "verbose" || logLevel === "info") {
165
- console.info(`[template] ${message}`);
166
- }
167
- } else if (level === "verbose") {
168
- if (logLevel === "verbose") {
169
- console.log(`[template] ${message}`);
170
- }
171
- }
172
- }
173
- exports.log = log2;
174
- }
175
- });
176
-
177
304
  // ../../packages/template-utils/lib/version.js
178
305
  var require_version = __commonJS({
179
306
  "../../packages/template-utils/lib/version.js"(exports) {
@@ -364,7 +491,7 @@ var require_parent = __commonJS({
364
491
  });
365
492
 
366
493
  // ../../node_modules/ejs/lib/utils.js
367
- var require_utils = __commonJS({
494
+ var require_utils2 = __commonJS({
368
495
  "../../node_modules/ejs/lib/utils.js"(exports) {
369
496
  "use strict";
370
497
  var regExpChars = /[|\\{}()[\]^$+*?.]/g;
@@ -486,7 +613,7 @@ var require_ejs = __commonJS({
486
613
  "use strict";
487
614
  var fs = require("fs");
488
615
  var path = require("path");
489
- var utils = require_utils();
616
+ var utils = require_utils2();
490
617
  var scopeOptionWarned = false;
491
618
  var _VERSION_STRING = require_package().version;
492
619
  var _DEFAULT_OPEN_DELIMITER = "<";
@@ -1041,108 +1168,6 @@ var require_ejs = __commonJS({
1041
1168
  }
1042
1169
  });
1043
1170
 
1044
- // ../../packages/template-utils/lib/utils.js
1045
- var require_utils2 = __commonJS({
1046
- "../../packages/template-utils/lib/utils.js"(exports) {
1047
- "use strict";
1048
- Object.defineProperty(exports, "__esModule", { value: true });
1049
- exports.getLanguageExtension = exports.getPlugins = exports.getPiralInstance = exports.getProjectJson = exports.getPackageJsonWithSource = exports.makeRelative = void 0;
1050
- var path_1 = require("path");
1051
- var fs_1 = require("fs");
1052
- var log_1 = require_log();
1053
- function makeRelative(path, root2) {
1054
- const relPath = (0, path_1.isAbsolute)(path) ? (0, path_1.relative)(root2, path) : path;
1055
- return relPath.split(path_1.sep).join(path_1.posix.sep);
1056
- }
1057
- exports.makeRelative = makeRelative;
1058
- function getPackageJsonWithSource(root2, targetDir, fileName) {
1059
- const path = makeRelative(path_1.posix.join(targetDir, fileName), root2);
1060
- (0, log_1.log)("verbose", `Adding "source" to package.json: "${path}"`);
1061
- return {
1062
- languages: ["ts", "js"],
1063
- name: "package.json",
1064
- content: JSON.stringify({ source: path }),
1065
- target: "<root>/package.json"
1066
- };
1067
- }
1068
- exports.getPackageJsonWithSource = getPackageJsonWithSource;
1069
- function getProjectJson(root2) {
1070
- try {
1071
- return require(`${root2}/package.json`);
1072
- } catch (ex) {
1073
- (0, log_1.log)("error", `Error when reading the "package.json": ${ex}`);
1074
- }
1075
- return void 0;
1076
- }
1077
- exports.getProjectJson = getProjectJson;
1078
- function getPiralInstance2(root2, sourceName) {
1079
- try {
1080
- const packageJsonPath = require.resolve(`${sourceName}/package.json`, {
1081
- paths: [root2]
1082
- });
1083
- (0, log_1.log)("verbose", `Found package JSON in "${packageJsonPath}"`);
1084
- const sourcePath = (0, path_1.dirname)(packageJsonPath);
1085
- const details = require(packageJsonPath);
1086
- const types = details.types || details.typings;
1087
- (0, log_1.log)("verbose", `Looking for types in "${types}"`);
1088
- const typingsPath = types !== void 0 ? (0, path_1.resolve)(sourcePath, types) : void 0;
1089
- const app = details.app;
1090
- (0, log_1.log)("verbose", `Looking for types in "${app}"`);
1091
- const appPath = app !== void 0 ? (0, path_1.resolve)(sourcePath, app) : void 0;
1092
- return {
1093
- sourceName,
1094
- sourcePath,
1095
- details,
1096
- appPath,
1097
- typingsPath
1098
- };
1099
- } catch (ex) {
1100
- (0, log_1.log)("error", `Error when getting Piral instance: ${ex}`);
1101
- }
1102
- return void 0;
1103
- }
1104
- exports.getPiralInstance = getPiralInstance2;
1105
- function getPlugins(root2, sourceName) {
1106
- const plugins = {};
1107
- (0, log_1.log)("verbose", `Getting the plugins of "${sourceName}/package.json" ...`);
1108
- const piralInstance = getPiralInstance2(root2, sourceName);
1109
- const typingsPath = piralInstance === null || piralInstance === void 0 ? void 0 : piralInstance.typingsPath;
1110
- if (typingsPath) {
1111
- (0, log_1.log)("verbose", `Reading file in "${typingsPath}"`);
1112
- const typing = (0, fs_1.readFileSync)(typingsPath, "utf8");
1113
- const match = /export interface PiletCustomApi extends (.*?) \{/g.exec(typing);
1114
- if (!match) {
1115
- (0, log_1.log)("verbose", `No Piral instance plugins have been found`);
1116
- return [];
1117
- }
1118
- const apis = match[1].split(", ");
1119
- (0, log_1.log)("verbose", `Found Piral instance plugins "${match[1]}"`);
1120
- for (const api of apis) {
1121
- const pluginMatch = /^Pilet(.*)Api$/.exec(api);
1122
- if (pluginMatch) {
1123
- const name = pluginMatch[1].toLowerCase();
1124
- plugins[name] = true;
1125
- } else {
1126
- (0, log_1.log)("warn", `Could not find plugin for Pilet API "${api}"`);
1127
- }
1128
- }
1129
- }
1130
- return plugins;
1131
- }
1132
- exports.getPlugins = getPlugins;
1133
- function getLanguageExtension(language, isJsx = true) {
1134
- switch (language) {
1135
- case "js":
1136
- return isJsx ? ".jsx" : ".js";
1137
- case "ts":
1138
- default:
1139
- return isJsx ? ".tsx" : ".ts";
1140
- }
1141
- }
1142
- exports.getLanguageExtension = getLanguageExtension;
1143
- }
1144
- });
1145
-
1146
1171
  // ../../packages/template-utils/lib/template.js
1147
1172
  var require_template = __commonJS({
1148
1173
  "../../packages/template-utils/lib/template.js"(exports) {
@@ -1179,7 +1204,7 @@ var require_template = __commonJS({
1179
1204
  var path_1 = require("path");
1180
1205
  var ejs_1 = require_ejs();
1181
1206
  var log_1 = require_log();
1182
- var utils_1 = require_utils2();
1207
+ var utils_1 = require_utils();
1183
1208
  var findVariable = /<(\w+)>/g;
1184
1209
  function replaceVariables(str, data) {
1185
1210
  let match = findVariable.exec(str);
@@ -1274,7 +1299,7 @@ var require_factory = __commonJS({
1274
1299
  var io_1 = require_io();
1275
1300
  var parent_1 = require_parent();
1276
1301
  var template_1 = require_template();
1277
- var utils_1 = require_utils2();
1302
+ var utils_1 = require_utils();
1278
1303
  function createPiletTemplateFactory2(templateRoot, getAllSources, defaultArgs = {}) {
1279
1304
  const sourceDir = (0, path_1.resolve)(templateRoot, "templates");
1280
1305
  return (projectRoot, args, details) => __awaiter(this, void 0, void 0, function* () {
@@ -1356,11 +1381,12 @@ var require_lib = __commonJS({
1356
1381
  __createBinding(exports2, m, p);
1357
1382
  };
1358
1383
  Object.defineProperty(exports, "__esModule", { value: true });
1384
+ __exportStar(require_bundler(), exports);
1359
1385
  __exportStar(require_factory(), exports);
1360
1386
  __exportStar(require_log(), exports);
1361
1387
  __exportStar(require_template(), exports);
1362
1388
  __exportStar(require_types(), exports);
1363
- __exportStar(require_utils2(), exports);
1389
+ __exportStar(require_utils(), exports);
1364
1390
  }
1365
1391
  });
1366
1392
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smapiot/pilet-template-angular",
3
- "version": "1.0.6-beta.6234",
3
+ "version": "1.0.7-beta.6240",
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.6-beta.6234"
57
+ "@smapiot/template-utils": "1.0.7-beta.6240"
58
58
  },
59
- "gitHead": "dc52c9d15a6754f5ca364c02bd49184579be4071"
59
+ "gitHead": "e4893a1a31c56d2445c283319d726a2bedf8264d"
60
60
  }