piral-cli 1.6.1-beta.7289 → 1.6.1

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 (70) hide show
  1. package/lib/apps/add-piral-instance-pilet.js +2 -0
  2. package/lib/apps/add-piral-instance-pilet.js.map +1 -1
  3. package/lib/apps/build-pilet.js +6 -0
  4. package/lib/apps/build-pilet.js.map +1 -1
  5. package/lib/apps/build-piral.js +6 -0
  6. package/lib/apps/build-piral.js.map +1 -1
  7. package/lib/apps/debug-pilet.js +6 -0
  8. package/lib/apps/debug-pilet.js.map +1 -1
  9. package/lib/apps/debug-piral.js +7 -0
  10. package/lib/apps/debug-piral.js.map +1 -1
  11. package/lib/apps/declaration-pilet.js +3 -0
  12. package/lib/apps/declaration-pilet.js.map +1 -1
  13. package/lib/apps/declaration-piral.js +3 -0
  14. package/lib/apps/declaration-piral.js.map +1 -1
  15. package/lib/apps/new-pilet.js +5 -0
  16. package/lib/apps/new-pilet.js.map +1 -1
  17. package/lib/apps/new-piral.js +7 -0
  18. package/lib/apps/new-piral.js.map +1 -1
  19. package/lib/apps/pack-pilet.js +3 -0
  20. package/lib/apps/pack-pilet.js.map +1 -1
  21. package/lib/apps/publish-pilet.js +5 -0
  22. package/lib/apps/publish-pilet.js.map +1 -1
  23. package/lib/apps/publish-piral.js +4 -0
  24. package/lib/apps/publish-piral.js.map +1 -1
  25. package/lib/apps/remove-piral-instance-pilet.js +3 -0
  26. package/lib/apps/remove-piral-instance-pilet.js.map +1 -1
  27. package/lib/apps/run-emulator-piral.js +2 -0
  28. package/lib/apps/run-emulator-piral.js.map +1 -1
  29. package/lib/apps/upgrade-pilet.js +3 -0
  30. package/lib/apps/upgrade-pilet.js.map +1 -1
  31. package/lib/apps/upgrade-piral.js +2 -0
  32. package/lib/apps/upgrade-piral.js.map +1 -1
  33. package/lib/apps/validate-pilet.js +2 -0
  34. package/lib/apps/validate-pilet.js.map +1 -1
  35. package/lib/apps/validate-piral.js +2 -0
  36. package/lib/apps/validate-piral.js.map +1 -1
  37. package/lib/commands.js.map +1 -1
  38. package/lib/common/constants.d.ts +1 -1
  39. package/lib/common/constants.js +1 -0
  40. package/lib/common/constants.js.map +1 -1
  41. package/lib/common/index.d.ts +1 -0
  42. package/lib/common/index.js +1 -0
  43. package/lib/common/index.js.map +1 -1
  44. package/lib/common/validate.d.ts +1 -0
  45. package/lib/common/validate.js +14 -0
  46. package/lib/common/validate.js.map +1 -0
  47. package/lib/external/index.js +9950 -7837
  48. package/package.json +2 -2
  49. package/src/apps/add-piral-instance-pilet.ts +5 -2
  50. package/src/apps/build-pilet.ts +9 -0
  51. package/src/apps/build-piral.ts +9 -0
  52. package/src/apps/debug-pilet.ts +9 -0
  53. package/src/apps/debug-piral.ts +10 -0
  54. package/src/apps/declaration-pilet.ts +6 -0
  55. package/src/apps/declaration-piral.ts +7 -2
  56. package/src/apps/new-pilet.ts +8 -0
  57. package/src/apps/new-piral.ts +10 -0
  58. package/src/apps/pack-pilet.ts +6 -1
  59. package/src/apps/publish-pilet.ts +8 -0
  60. package/src/apps/publish-piral.ts +14 -4
  61. package/src/apps/remove-piral-instance-pilet.ts +6 -0
  62. package/src/apps/run-emulator-piral.ts +5 -0
  63. package/src/apps/upgrade-pilet.ts +6 -0
  64. package/src/apps/upgrade-piral.ts +5 -0
  65. package/src/apps/validate-pilet.ts +5 -1
  66. package/src/apps/validate-piral.ts +5 -1
  67. package/src/commands.ts +0 -1
  68. package/src/common/constants.ts +1 -0
  69. package/src/common/index.ts +1 -0
  70. package/src/common/validate.ts +11 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "piral-cli",
3
- "version": "1.6.1-beta.7289",
3
+ "version": "1.6.1",
4
4
  "description": "The standard CLI for creating and building a Piral instance or a Pilet.",
5
5
  "keywords": [
6
6
  "portal",
@@ -81,5 +81,5 @@
81
81
  "typescript": "^5.0.0",
82
82
  "yargs": "^15.0.0"
83
83
  },
84
- "gitHead": "4748c3524b1da3cd677f2f8d299ce11ce7f1bd42"
84
+ "gitHead": "9fc8bab4468f424e458f5a5c75ba051a196624f5"
85
85
  }
@@ -6,13 +6,12 @@ import {
6
6
  log,
7
7
  matchAnyPilet,
8
8
  findFile,
9
- readJson,
10
- writeJson,
11
9
  logDone,
12
10
  installPiralInstance,
13
11
  determineNpmClient,
14
12
  findPiletRoot,
15
13
  piletJson,
14
+ ensure,
16
15
  } from '../common';
17
16
 
18
17
  export interface AddPiralInstancePiletOptions {
@@ -59,6 +58,10 @@ export async function addPiralInstancePilet(baseDir = process.cwd(), options: Ad
59
58
  selected = addPiralInstancePiletDefaults.selected,
60
59
  app = addPiralInstancePiletDefaults.app,
61
60
  } = options;
61
+
62
+ ensure('baseDir', baseDir, 'string');
63
+ ensure('source', source, 'string');
64
+
62
65
  const fullBase = resolve(process.cwd(), baseDir);
63
66
  setLogLevel(logLevel);
64
67
  progress('Reading configuration ...');
@@ -24,6 +24,7 @@ import {
24
24
  triggerBuildPilet,
25
25
  readText,
26
26
  writeText,
27
+ ensure,
27
28
  } from '../common';
28
29
 
29
30
  interface PiletData {
@@ -199,6 +200,14 @@ export async function buildPilet(baseDir = process.cwd(), options: BuildPiletOpt
199
200
  bundlerName,
200
201
  app,
201
202
  } = options;
203
+
204
+ ensure('baseDir', baseDir, 'string');
205
+ ensure('publicUrl', originalPublicUrl, 'string');
206
+ ensure('entry', entry, 'string');
207
+ ensure('_', _, 'object');
208
+ ensure('hooks', hooks, 'object');
209
+ ensure('target', target, 'string');
210
+
202
211
  const publicUrl = normalizePublicUrl(originalPublicUrl);
203
212
  const fullBase = resolve(process.cwd(), baseDir);
204
213
  const entryList = Array.isArray(entry) ? entry : [entry];
@@ -19,6 +19,7 @@ import {
19
19
  releaseName,
20
20
  triggerBuildEmulator,
21
21
  triggerBuildShell,
22
+ ensure,
22
23
  } from '../common';
23
24
 
24
25
  export interface BuildPiralOptions {
@@ -140,6 +141,14 @@ export async function buildPiral(baseDir = process.cwd(), options: BuildPiralOpt
140
141
  hooks = {},
141
142
  bundlerName,
142
143
  } = options;
144
+
145
+ ensure('baseDir', baseDir, 'string');
146
+ ensure('publicUrl', originalPublicUrl, 'string');
147
+ ensure('entry', entry, 'string');
148
+ ensure('_', _, 'object');
149
+ ensure('hooks', hooks, 'object');
150
+ ensure('target', target, 'string');
151
+
143
152
  const publicUrl = normalizePublicUrl(originalPublicUrl);
144
153
  const fullBase = resolve(process.cwd(), baseDir);
145
154
  const useSubdir = type === 'all' || subdir;
@@ -23,6 +23,7 @@ import {
23
23
  packageJson,
24
24
  piletJson,
25
25
  defaultSchemaVersion,
26
+ ensure,
26
27
  } from '../common';
27
28
 
28
29
  export interface DebugPiletOptions {
@@ -235,6 +236,14 @@ export async function debugPilet(baseDir = process.cwd(), options: DebugPiletOpt
235
236
  appInstanceDir,
236
237
  feed,
237
238
  } = options;
239
+
240
+ ensure('baseDir', baseDir, 'string');
241
+ ensure('_', _, 'object');
242
+ ensure('hooks', hooks, 'object');
243
+ ensure('target', target, 'string');
244
+ ensure('publicUrl', originalPublicUrl, 'string');
245
+ ensure('port', originalPort, ['number', 'undefined']);
246
+
238
247
  const publicUrl = normalizePublicUrl(originalPublicUrl);
239
248
  const fullBase = resolve(process.cwd(), baseDir);
240
249
  const networks: Array<NetworkSpec> = [];
@@ -17,6 +17,7 @@ import {
17
17
  piralJson,
18
18
  packageJson,
19
19
  flattenExternals,
20
+ ensure,
20
21
  } from '../common';
21
22
 
22
23
  export interface DebugPiralOptions {
@@ -129,6 +130,15 @@ export async function debugPiral(baseDir = process.cwd(), options: DebugPiralOpt
129
130
  hooks = {},
130
131
  bundlerName,
131
132
  } = options;
133
+
134
+ ensure('baseDir', baseDir, 'string');
135
+ ensure('publicUrl', originalPublicUrl, 'string');
136
+ ensure('port', originalPort, ['number', 'undefined']);
137
+ ensure('entry', entry, 'string');
138
+ ensure('_', _, 'object');
139
+ ensure('hooks', hooks, 'object');
140
+ ensure('target', target, 'string');
141
+
132
142
  const publicUrl = normalizePublicUrl(originalPublicUrl);
133
143
  const fullBase = resolve(process.cwd(), baseDir);
134
144
  const network: NetworkSpec = {
@@ -7,6 +7,7 @@ import {
7
7
  matchAnyPilet,
8
8
  retrievePiletData,
9
9
  combinePiletExternals,
10
+ ensure,
10
11
  } from '../common';
11
12
  import { LogLevels } from '../types';
12
13
 
@@ -47,6 +48,11 @@ export async function declarationPilet(baseDir = process.cwd(), options: Declara
47
48
  forceOverwrite = declarationPiletDefaults.forceOverwrite,
48
49
  logLevel = declarationPiletDefaults.logLevel,
49
50
  } = options;
51
+
52
+ ensure('baseDir', baseDir, 'string');
53
+ ensure('entry', entry, 'string');
54
+ ensure('target', target, 'string');
55
+
50
56
  const entryList = Array.isArray(entry) ? entry : [entry];
51
57
  const fullBase = resolve(process.cwd(), baseDir);
52
58
  setLogLevel(logLevel);
@@ -1,5 +1,5 @@
1
1
  import { resolve } from 'path';
2
- import { setLogLevel, logDone, createPiralDeclaration, ForceOverwrite } from '../common';
2
+ import { setLogLevel, logDone, createPiralDeclaration, ForceOverwrite, ensure } from '../common';
3
3
  import { LogLevels } from '../types';
4
4
 
5
5
  export interface DeclarationPiralOptions {
@@ -38,9 +38,14 @@ export async function declarationPiral(baseDir = process.cwd(), options: Declara
38
38
  forceOverwrite = declarationPiralDefaults.forceOverwrite,
39
39
  logLevel = declarationPiralDefaults.logLevel,
40
40
  } = options;
41
+
42
+ ensure('baseDir', baseDir, 'string');
43
+ ensure('entry', entry, 'string');
44
+ ensure('target', target, 'string');
45
+
41
46
  const fullBase = resolve(process.cwd(), baseDir);
42
47
  setLogLevel(logLevel);
43
-
48
+
44
49
  if (await createPiralDeclaration(fullBase, entry, target, forceOverwrite, logLevel)) {
45
50
  logDone(`Declaration created successfully in "${target}"!`);
46
51
  }
@@ -28,6 +28,7 @@ import {
28
28
  piletJson,
29
29
  defaultSchemaVersion,
30
30
  piletJsonSchemaUrl,
31
+ ensure,
31
32
  } from '../common';
32
33
 
33
34
  export interface NewPiletOptions {
@@ -126,6 +127,13 @@ export async function newPilet(baseDir = process.cwd(), options: NewPiletOptions
126
127
  npmClient: defaultNpmClient = newPiletDefaults.npmClient,
127
128
  name = newPiletDefaults.name,
128
129
  } = options;
130
+
131
+ ensure('baseDir', baseDir, 'string');
132
+ ensure('source', source, 'string');
133
+ ensure('target', target, 'string');
134
+ ensure('template', template, ['string', 'undefined']);
135
+ ensure('variables', variables, 'object');
136
+
129
137
  const fullBase = resolve(process.cwd(), baseDir);
130
138
  const root = resolve(fullBase, target);
131
139
  setLogLevel(logLevel);
@@ -20,6 +20,7 @@ import {
20
20
  config,
21
21
  initNpmProject,
22
22
  piralJson,
23
+ ensure,
23
24
  } from '../common';
24
25
 
25
26
  export interface NewPiralOptions {
@@ -128,6 +129,15 @@ export async function newPiral(baseDir = process.cwd(), options: NewPiralOptions
128
129
  name = newPiralDefaults.name,
129
130
  npmClient: defaultNpmClient = newPiralDefaults.npmClient,
130
131
  } = options;
132
+
133
+ ensure('baseDir', baseDir, 'string');
134
+ ensure('framework', framework, 'string');
135
+ ensure('version', version, 'string');
136
+ ensure('target', target, 'string');
137
+ ensure('app', app, 'string');
138
+ ensure('template', template, 'string');
139
+ ensure('variables', variables, 'object');
140
+
131
141
  const fullBase = resolve(process.cwd(), baseDir);
132
142
  const root = resolve(fullBase, target);
133
143
 
@@ -1,5 +1,5 @@
1
1
  import { resolve } from 'path';
2
- import { createPiletPackage, logDone, setLogLevel, progress } from '../common';
2
+ import { createPiletPackage, logDone, setLogLevel, progress, ensure } from '../common';
3
3
  import { LogLevels } from '../types';
4
4
 
5
5
  export interface PackPiletOptions {
@@ -31,6 +31,11 @@ export async function packPilet(baseDir = process.cwd(), options: PackPiletOptio
31
31
  target = packPiletDefaults.target,
32
32
  logLevel = packPiletDefaults.logLevel,
33
33
  } = options;
34
+
35
+ ensure('baseDir', baseDir, 'string');
36
+ ensure('source', source, 'string');
37
+ ensure('target', target, 'string');
38
+
34
39
  const fullBase = resolve(process.cwd(), baseDir);
35
40
  setLogLevel(logLevel);
36
41
  progress('Reading configuration ...');
@@ -16,6 +16,7 @@ import {
16
16
  matchAnyPilet,
17
17
  triggerBuildPilet,
18
18
  getCertificate,
19
+ ensure,
19
20
  } from '../common';
20
21
 
21
22
  export interface PublishPiletOptions {
@@ -212,6 +213,13 @@ export async function publishPilet(baseDir = process.cwd(), options: PublishPile
212
213
  hooks = {},
213
214
  bundlerName,
214
215
  } = options;
216
+
217
+ ensure('baseDir', baseDir, 'string');
218
+ ensure('headers', headers, 'object');
219
+ ensure('fields', fields, 'object');
220
+ ensure('_', _, 'object');
221
+ ensure('hooks', hooks, 'object');
222
+
215
223
  const fullBase = resolve(process.cwd(), baseDir);
216
224
  setLogLevel(logLevel);
217
225
  progress('Reading configuration ...');
@@ -24,6 +24,7 @@ import {
24
24
  packageJson,
25
25
  triggerBuildShell,
26
26
  publishPackageEmulator,
27
+ ensure,
27
28
  } from '../common';
28
29
 
29
30
  export interface PublishPiralOptions {
@@ -128,6 +129,12 @@ export async function publishPiral(baseDir = process.cwd(), options: PublishPira
128
129
  hooks = {},
129
130
  bundlerName,
130
131
  } = options;
132
+
133
+ ensure('baseDir', baseDir, 'string');
134
+ ensure('headers', headers, 'object');
135
+ ensure('_', _, 'object');
136
+ ensure('hooks', hooks, 'object');
137
+
131
138
  const fullBase = resolve(process.cwd(), baseDir);
132
139
  setLogLevel(logLevel);
133
140
  progress('Reading configuration ...');
@@ -150,7 +157,10 @@ export async function publishPiral(baseDir = process.cwd(), options: PublishPira
150
157
  } = await retrievePiletsInfo(entryFiles);
151
158
 
152
159
  if (type === 'emulator' && ![emulatorPackageName, emulatorWebsiteName].includes(emulator)) {
153
- fail('generalError_0002', `The emulator type "${emulator}" is not supported. Select one of these types to use the publish command: "${emulatorWebsiteName}", "${emulatorPackageName}".`);
160
+ fail(
161
+ 'generalError_0002',
162
+ `The emulator type "${emulator}" is not supported. Select one of these types to use the publish command: "${emulatorWebsiteName}", "${emulatorPackageName}".`,
163
+ );
154
164
  }
155
165
 
156
166
  const dir = type === 'release' ? releaseName : emulatorName;
@@ -225,7 +235,7 @@ export async function publishPiral(baseDir = process.cwd(), options: PublishPira
225
235
  }
226
236
 
227
237
  progress(`Published successfully!`);
228
-
238
+
229
239
  logDone(`Release artifacts published successfully!`);
230
240
  } else if (emulator === emulatorWebsiteName) {
231
241
  const { version } = await readJson(targetDir, emulatorJson);
@@ -250,7 +260,7 @@ export async function publishPiral(baseDir = process.cwd(), options: PublishPira
250
260
  }
251
261
 
252
262
  progress(`Published successfully!`);
253
-
263
+
254
264
  logDone(`Emulator published successfully!`);
255
265
  } else if (emulator === emulatorPackageName) {
256
266
  log('generalInfo_0000', `Using npm registry "${url}".`);
@@ -271,7 +281,7 @@ export async function publishPiral(baseDir = process.cwd(), options: PublishPira
271
281
  } catch {
272
282
  fail('failedUploading_0064');
273
283
  }
274
-
284
+
275
285
  logDone(`Emulator published successfully!`);
276
286
  } else {
277
287
  // we should not enter here - anyway let's do nothing
@@ -13,6 +13,7 @@ import {
13
13
  determineNpmClient,
14
14
  uninstallNpmPackage,
15
15
  piletJson,
16
+ ensure,
16
17
  } from '../common';
17
18
 
18
19
  export interface RemovePiralInstancePiletOptions {
@@ -52,6 +53,11 @@ export async function removePiralInstancePilet(baseDir = process.cwd(), options:
52
53
  source = removePiralInstancePiletDefaults.source,
53
54
  app = removePiralInstancePiletDefaults.app,
54
55
  } = options;
56
+
57
+ ensure('baseDir', baseDir, 'string');
58
+ ensure('source', source, 'string');
59
+ ensure('app', app, 'string');
60
+
55
61
  const fullBase = resolve(process.cwd(), baseDir);
56
62
  setLogLevel(logLevel);
57
63
  progress('Reading configuration ...');
@@ -17,6 +17,7 @@ import {
17
17
  ForceOverwrite,
18
18
  findPiralInstance,
19
19
  determineNpmClient,
20
+ ensure,
20
21
  } from '../common';
21
22
 
22
23
  export interface RunEmulatorPiralOptions {
@@ -96,6 +97,10 @@ export async function runEmulatorPiral(baseDir = process.cwd(), options: RunEmul
96
97
  app,
97
98
  feed,
98
99
  } = options;
100
+
101
+ ensure('baseDir', baseDir, 'string');
102
+ ensure('app', app, 'string');
103
+
99
104
  const publicUrl = '/';
100
105
  const api = config.piletApi;
101
106
  const fullBase = resolve(process.cwd(), baseDir);
@@ -25,6 +25,7 @@ import {
25
25
  isMonorepoPackageRef,
26
26
  getPiletScaffoldData,
27
27
  retrievePiletData,
28
+ ensure,
28
29
  } from '../common';
29
30
 
30
31
  export interface UpgradePiletOptions {
@@ -90,6 +91,11 @@ export async function upgradePilet(baseDir = process.cwd(), options: UpgradePile
90
91
  variables = upgradePiletDefaults.variables,
91
92
  npmClient: defaultNpmClient = upgradePiletDefaults.npmClient,
92
93
  } = options;
94
+
95
+ ensure('baseDir', baseDir, 'string');
96
+ ensure('variables', variables, 'object');
97
+ ensure('target', target, 'string');
98
+
93
99
  const fullBase = resolve(process.cwd(), baseDir);
94
100
  const root = resolve(fullBase, target);
95
101
  setLogLevel(logLevel);
@@ -14,6 +14,7 @@ import {
14
14
  repositoryUrl,
15
15
  findSpecificVersion,
16
16
  determineNpmClient,
17
+ ensure,
17
18
  } from '../common';
18
19
 
19
20
  export interface UpgradePiralOptions {
@@ -82,6 +83,10 @@ export async function upgradePiral(baseDir = process.cwd(), options: UpgradePira
82
83
  install = upgradePiralDefaults.install,
83
84
  npmClient: defaultNpmClient = upgradePiralDefaults.npmClient,
84
85
  } = options;
86
+
87
+ ensure('baseDir', baseDir, 'string');
88
+ ensure('target', target, 'string');
89
+
85
90
  const fullBase = resolve(process.cwd(), baseDir);
86
91
  const root = resolve(fullBase, target);
87
92
  setLogLevel(logLevel);
@@ -1,5 +1,5 @@
1
1
  import { join, dirname, resolve } from 'path';
2
- import { ruleSummary, runRules, retrievePiletData, getPiletsInfo, setLogLevel, progress, log } from '../common';
2
+ import { ruleSummary, runRules, retrievePiletData, getPiletsInfo, setLogLevel, progress, log, ensure } from '../common';
3
3
  import { getPiletRules } from '../rules';
4
4
  import { PiletRuleContext, LogLevels } from '../types';
5
5
 
@@ -32,6 +32,10 @@ export async function validatePilet(baseDir = process.cwd(), options: ValidatPil
32
32
  logLevel = validatePiletDefaults.logLevel,
33
33
  app = validatePiletDefaults.app,
34
34
  } = options;
35
+
36
+ ensure('baseDir', baseDir, 'string');
37
+ ensure('entry', entry, 'string');
38
+
35
39
  const fullBase = resolve(process.cwd(), baseDir);
36
40
  setLogLevel(logLevel);
37
41
  progress('Reading configuration ...');
@@ -1,5 +1,5 @@
1
1
  import { resolve } from 'path';
2
- import { retrievePiralRoot, retrievePiletsInfo, ruleSummary, runRules, config } from '../common';
2
+ import { retrievePiralRoot, retrievePiletsInfo, ruleSummary, runRules, config, ensure } from '../common';
3
3
  import { setLogLevel, progress, log, checkCliCompatibility } from '../common';
4
4
  import { getPiralRules } from '../rules';
5
5
  import { LogLevels, PiralRuleContext } from '../types';
@@ -23,6 +23,10 @@ export const validatePiralDefaults: ValidatPiralOptions = {
23
23
 
24
24
  export async function validatePiral(baseDir = process.cwd(), options: ValidatPiralOptions = {}) {
25
25
  const { entry = validatePiralDefaults.entry, logLevel = validatePiralDefaults.logLevel } = options;
26
+
27
+ ensure('baseDir', baseDir, 'string');
28
+ ensure('entry', entry, 'string');
29
+
26
30
  const fullBase = resolve(process.cwd(), baseDir);
27
31
  setLogLevel(logLevel);
28
32
  progress('Reading configuration ...');
package/src/commands.ts CHANGED
@@ -2,7 +2,6 @@ import * as apps from './apps';
2
2
  import {
3
3
  piletBuildTypeKeys,
4
4
  availableBundlers,
5
- availableReleaseProviders,
6
5
  forceOverwriteKeys,
7
6
  keyOfForceOverwrite,
8
7
  valueOfForceOverwrite,
@@ -28,6 +28,7 @@ export const bundlerNames = [
28
28
  'webpack' as const,
29
29
  'webpack5' as const,
30
30
  'vite' as const,
31
+ 'vite5' as const,
31
32
  'xbuild' as const,
32
33
  ];
33
34
  export const declarationEntryExtensions = ['.html', '.pug', ...entryModuleExtensions];
@@ -37,6 +37,7 @@ export * from './shell';
37
37
  export * from './spec';
38
38
  export * from './template';
39
39
  export * from './url';
40
+ export * from './validate';
40
41
  export * from './version';
41
42
  export * from './watcher';
42
43
  export * from './website';
@@ -0,0 +1,11 @@
1
+ import { fail } from './log';
2
+
3
+ export function ensure(name: string, value: any, expectedType: string | Array<string>) {
4
+ const actualType = typeof value;
5
+ const expectedTypes = Array.isArray(expectedType) ? expectedType : [expectedType];
6
+
7
+ if (!expectedTypes.includes(actualType)) {
8
+ const type = expectedTypes.length === 1 ? `"${expectedTypes[0]}"` : `one of "${expectedTypes.join('", "')}"`;
9
+ fail('generalError_0002', `The type for "${name}" is invalid - it should be ${type}, but was "${actualType}".`);
10
+ }
11
+ }