@tywalk/pcf-helper-run 1.1.20 → 1.1.22

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/dist/index.js CHANGED
@@ -3,15 +3,13 @@
3
3
  var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  return (mod && mod.__esModule) ? mod : { "default": mod };
5
5
  };
6
- var _a, _b, _c, _d;
6
+ var _a, _b, _c;
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
- const upgrade_pcf_1 = __importDefault(require("@tywalk/pcf-helper/dist/tasks/upgrade-pcf"));
9
- const build_pcf_1 = __importDefault(require("@tywalk/pcf-helper/dist/tasks/build-pcf"));
10
- const import_pcf_1 = __importDefault(require("@tywalk/pcf-helper/dist/tasks/import-pcf"));
11
- const init_pcf_1 = __importDefault(require("@tywalk/pcf-helper/dist/tasks/init-pcf"));
8
+ const pcf_helper_1 = __importDefault(require("@tywalk/pcf-helper"));
12
9
  const color_logger_1 = require("@tywalk/color-logger");
13
10
  const package_json_1 = require("./package.json");
14
11
  const performanceUtil_1 = require("./util/performanceUtil");
12
+ const argumentUtil_1 = require("./util/argumentUtil");
15
13
  const [, , ...args] = process.argv;
16
14
  const commandArgument = (_b = (_a = args.at(0)) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== null && _b !== void 0 ? _b : '';
17
15
  if (['-v', '--version'].includes(commandArgument)) {
@@ -20,52 +18,66 @@ if (['-v', '--version'].includes(commandArgument)) {
20
18
  }
21
19
  const logger = new color_logger_1.Logger('log');
22
20
  const verboseArgument = args.find(a => ['-v', '--verbose'].includes(a));
23
- if (typeof verboseArgument !== 'undefined') {
21
+ const isVerbose = verboseArgument !== undefined;
22
+ if (isVerbose) {
24
23
  logger.setDebug(true);
25
24
  }
26
25
  logger.log('PCF Helper Run version\n', package_json_1.version);
27
26
  if (typeof commandArgument === 'undefined' || !['upgrade', 'build', 'import', 'deploy', 'init'].includes(commandArgument)) {
28
- logger.error('Command [command] (upgrade, build, import, deploy) is required.');
27
+ logger.error('Command [command] (upgrade, build, import, deploy, init) is required.');
29
28
  process.exit(1);
30
29
  }
31
30
  const runAll = commandArgument === 'deploy';
32
- const pathArgument = args.find(a => ['-p', '--path'].includes(a));
33
- if (typeof pathArgument === 'undefined') {
34
- logger.error('Path argument is required. Use --path to specify the path to solution folder.');
35
- process.exit(1);
36
- }
37
- const pathIndex = args.indexOf(pathArgument) + 1;
38
- const path = args.at(pathIndex);
31
+ const runInit = commandArgument === 'init';
32
+ const path = (0, argumentUtil_1.getArgValue)(args, ['-p', '--path']);
39
33
  if (typeof path === 'undefined') {
40
- logger.error('Path argument is required. Use --path to specify the path to solution folder.');
34
+ if (runInit) {
35
+ logger.error('Path argument is required. Use --path to specify the PCF folder.');
36
+ }
37
+ else {
38
+ logger.error('Path argument is required. Use --path to specify the path to solution folder.');
39
+ }
41
40
  process.exit(1);
42
41
  }
43
42
  const tick = performance.now();
44
- const envArgument = (_c = args.find(a => ['-env', '--environment'].includes(a))) !== null && _c !== void 0 ? _c : '';
45
- let envIndex = args.indexOf(envArgument) + 1;
46
- let env = '';
47
- if (envIndex > 0) {
48
- env = (_d = args.at(envIndex)) !== null && _d !== void 0 ? _d : '';
43
+ const env = (_c = (0, argumentUtil_1.getArgValue)(args, ['-env', '--environment'])) !== null && _c !== void 0 ? _c : '';
44
+ if (env === '' && !runInit) {
45
+ logger.warn('No environment specified. Defaulting to "local".');
49
46
  }
50
47
  function executeTasks() {
51
48
  if (commandArgument === 'upgrade' || runAll) {
52
- const upgradeResult = upgrade_pcf_1.default.run(path);
49
+ const upgradeResult = pcf_helper_1.default.runUpgrade(path, isVerbose);
53
50
  if (upgradeResult === 1)
54
51
  return 1;
55
52
  }
56
53
  if (commandArgument === 'build' || runAll) {
57
- const buildResult = build_pcf_1.default.run(path);
54
+ const buildResult = pcf_helper_1.default.runBuild(path, isVerbose);
58
55
  if (buildResult === 1)
59
56
  return 1;
60
57
  }
61
58
  if (commandArgument === 'import' || runAll) {
62
- const importResult = import_pcf_1.default.run(path, env);
59
+ const importResult = pcf_helper_1.default.runImport(path, env, isVerbose);
63
60
  if (importResult === 1)
64
61
  return 1;
65
62
  }
66
63
  if (commandArgument === 'init') {
67
- const importResult = init_pcf_1.default.run(path, env);
68
- if (importResult === 1)
64
+ const name = (0, argumentUtil_1.getArgValue)(args, ['-n', '--name']);
65
+ const publisherName = (0, argumentUtil_1.getArgValue)(args, ['-pn', '--publisher-name']);
66
+ const publisherPrefix = (0, argumentUtil_1.getArgValue)(args, ['-pp', '--publisher-prefix']);
67
+ if (typeof name === 'undefined') {
68
+ logger.error('Name argument is required. Use --name to specify the name of the control.');
69
+ process.exit(1);
70
+ }
71
+ if (typeof publisherName === 'undefined') {
72
+ logger.error('Publisher Name argument is required. Use --publisher-name to specify the name of the control.');
73
+ process.exit(1);
74
+ }
75
+ if (typeof publisherPrefix === 'undefined') {
76
+ logger.error('Publisher Prefix argument is required. Use --publisher-prefix to specify the name of the control.');
77
+ process.exit(1);
78
+ }
79
+ const initResult = pcf_helper_1.default.runInit(path, name, publisherName, publisherPrefix, isVerbose);
80
+ if (initResult === 1)
69
81
  return 1;
70
82
  }
71
83
  return 0;
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tywalk/pcf-helper-run",
3
- "version": "1.1.20",
3
+ "version": "1.1.22",
4
4
  "description": "A simple command-line utility for building and publishing PCF controls to Dataverse.",
5
5
  "types": "./types/",
6
6
  "files": [
@@ -25,7 +25,7 @@
25
25
  },
26
26
  "dependencies": {
27
27
  "@tywalk/color-logger": "^1.0.3",
28
- "@tywalk/pcf-helper": "^1.4.16"
28
+ "@tywalk/pcf-helper": "^1.4.20"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@types/jest": "^29.5.14",
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getArg = getArg;
4
+ exports.getArgValue = getArgValue;
5
+ function getArg(args, arg) {
6
+ const index = args.indexOf(arg);
7
+ if (index !== -1 && index + 1 < args.length) {
8
+ return args[index + 1];
9
+ }
10
+ return undefined;
11
+ }
12
+ function getArgValue(args, argOpts) {
13
+ const arg = args.find(a => argOpts.includes(a));
14
+ if (typeof arg === 'undefined') {
15
+ return undefined;
16
+ }
17
+ const argIndex = args.indexOf(arg) + 1;
18
+ return args.at(argIndex);
19
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tywalk/pcf-helper-run",
3
- "version": "1.1.20",
3
+ "version": "1.1.22",
4
4
  "description": "A simple command-line utility for building and publishing PCF controls to Dataverse.",
5
5
  "types": "./types/",
6
6
  "files": [
@@ -25,7 +25,7 @@
25
25
  },
26
26
  "dependencies": {
27
27
  "@tywalk/color-logger": "^1.0.3",
28
- "@tywalk/pcf-helper": "^1.4.16"
28
+ "@tywalk/pcf-helper": "^1.4.20"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@types/jest": "^29.5.14",
@@ -0,0 +1,2 @@
1
+ export declare function getArg(args: string[], arg: string): string | undefined;
2
+ export declare function getArgValue(args: string[], argOpts: string[]): string | undefined;