@tywalk/pcf-helper 1.4.18 → 1.4.21

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.
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const child_process_1 = require("child_process");
4
+ const package_json_1 = require("../package.json");
5
+ test('init displays version', (done) => {
6
+ const task = (0, child_process_1.spawn)('node', ['./dist/bin/init.js', '-v']);
7
+ let output = '';
8
+ task.stdout.on('data', (data) => {
9
+ output += data.toString();
10
+ });
11
+ task.on('close', (code) => {
12
+ console.log(output);
13
+ expect(output).toContain(package_json_1.version);
14
+ expect(code).toBe(0);
15
+ done();
16
+ });
17
+ });
18
+ test('init errors if no path is provided', (done) => {
19
+ const task = (0, child_process_1.spawn)('node', ['./dist/bin/init.js', '-p']);
20
+ let output = '';
21
+ task.stdout.on('data', (data) => {
22
+ output += data.toString();
23
+ });
24
+ task.stderr.on('data', (data) => {
25
+ console.error(`stderr: ${data}`);
26
+ });
27
+ task.on('close', (code) => {
28
+ console.log(output);
29
+ expect(code).toBe(1);
30
+ done();
31
+ });
32
+ });
33
+ // test('init creates pcf', () => {
34
+ // logger.setDebug(true);
35
+ // const result = runInit('./tests', 'test', 'testpb', 'tb', false, true);
36
+ // expect(result).toBe(0);
37
+ // });
package/dist/bin/build.js CHANGED
@@ -63,4 +63,4 @@ if (typeof path === 'undefined') {
63
63
  color_logger_1.default.error('Path argument is required. Use --path to specify the path to solution folder.');
64
64
  process.exit(1);
65
65
  }
66
- task.run(path, verboseArgument !== undefined);
66
+ task.runBuild(path, verboseArgument !== undefined);
@@ -74,13 +74,13 @@ if (envIndex > 0) {
74
74
  env = (_d = args.at(envIndex)) !== null && _d !== void 0 ? _d : '';
75
75
  }
76
76
  function executeTasks() {
77
- const upgradeResult = upgradeTask.run(path, typeof verboseArgument !== 'undefined');
77
+ const upgradeResult = upgradeTask.runUpgrade(path, typeof verboseArgument !== 'undefined');
78
78
  if (upgradeResult === 1)
79
79
  return 1;
80
- const buildResult = buildTask.run(path, typeof verboseArgument !== 'undefined');
80
+ const buildResult = buildTask.runBuild(path, typeof verboseArgument !== 'undefined');
81
81
  if (buildResult === 1)
82
82
  return 1;
83
- const importResult = importTask.run(path, env, typeof verboseArgument !== 'undefined');
83
+ const importResult = importTask.runImport(path, env, typeof verboseArgument !== 'undefined');
84
84
  if (importResult === 1)
85
85
  return 1;
86
86
  return 0;
@@ -69,4 +69,4 @@ let env = '';
69
69
  if (envIndex > 0) {
70
70
  env = (_d = args.at(envIndex)) !== null && _d !== void 0 ? _d : '';
71
71
  }
72
- task.run(path, env);
72
+ task.runImport(path, env);
package/dist/bin/init.js CHANGED
@@ -36,7 +36,7 @@ var __importStar = (this && this.__importStar) || (function () {
36
36
  var __importDefault = (this && this.__importDefault) || function (mod) {
37
37
  return (mod && mod.__esModule) ? mod : { "default": mod };
38
38
  };
39
- var _a, _b, _c, _d, _e;
39
+ var _a, _b, _c, _d, _e, _f;
40
40
  Object.defineProperty(exports, "__esModule", { value: true });
41
41
  const task = __importStar(require("../tasks/init-pcf"));
42
42
  const package_json_1 = require("../package.json");
@@ -81,4 +81,10 @@ if (typeof pathArgument !== 'undefined') {
81
81
  const pathIndex = args.indexOf(pathArgument) + 1;
82
82
  path = (_e = args.at(pathIndex)) !== null && _e !== void 0 ? _e : '';
83
83
  }
84
- task.run(path, name, publisherName, publisherPrefix, verboseArgument !== undefined);
84
+ let npm = '';
85
+ const npmArgument = args.find(a => ['-npm', '--run-npm-install'].includes(a));
86
+ if (typeof npmArgument !== 'undefined') {
87
+ const pathIndex = args.indexOf(npmArgument) + 1;
88
+ npm = (_f = args.at(pathIndex)) !== null && _f !== void 0 ? _f : '';
89
+ }
90
+ task.runInit(path, name, publisherName, publisherPrefix, npm === 'true', verboseArgument !== undefined);
@@ -63,4 +63,4 @@ if (typeof path === 'undefined') {
63
63
  color_logger_1.default.error('Path argument is required. Use --path to specify the path to solution folder.');
64
64
  process.exit(1);
65
65
  }
66
- task.run(path, verboseArgument !== undefined);
66
+ task.runUpgrade(path, verboseArgument !== undefined);
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tywalk/pcf-helper",
3
- "version": "1.4.18",
3
+ "version": "1.4.21",
4
4
  "description": "Command line helper for building and publishing PCF controls to Dataverse.",
5
5
  "main": "dist/index.js",
6
6
  "types": "./types/",
@@ -15,7 +15,7 @@
15
15
  "test": "jest",
16
16
  "build": "tsc",
17
17
  "upgrade": "npm version patch --no-git-tag-version",
18
- "ready": "npm run upgrade && npm run build"
18
+ "ready": "npm run upgrade"
19
19
  },
20
20
  "keywords": [
21
21
  "pcf"
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.run = run;
6
+ exports.runBuild = runBuild;
7
7
  const child_process_1 = require("child_process");
8
8
  const performanceUtil_1 = require("../util/performanceUtil");
9
9
  const color_logger_1 = __importDefault(require("@tywalk/color-logger"));
@@ -15,7 +15,7 @@ const color_logger_1 = __importDefault(require("@tywalk/color-logger"));
15
15
  *
16
16
  * @returns {number} The exit code of the spawned process.
17
17
  */
18
- function run(path, verbose) {
18
+ function runBuild(path, verbose) {
19
19
  color_logger_1.default.log('[PCF Helper] ' + (0, performanceUtil_1.formatTime)(new Date()) + ' Starting build...\n');
20
20
  const tick = performance.now();
21
21
  const task = (0, child_process_1.spawnSync)('dotnet build', ['--restore', '-c', 'Release', path], {
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.run = run;
6
+ exports.runImport = runImport;
7
7
  const child_process_1 = require("child_process");
8
8
  const path_1 = require("path");
9
9
  const fs_1 = __importDefault(require("fs"));
@@ -18,7 +18,7 @@ const performanceUtil_1 = require("../util/performanceUtil");
18
18
  *
19
19
  * @returns {number} The exit status of the import process.
20
20
  */
21
- function run(path, env, verbose) {
21
+ function runImport(path, env, verbose) {
22
22
  var _a;
23
23
  color_logger_1.default.log('[PCF Helper] ' + (0, performanceUtil_1.formatTime)(new Date()) + ' Starting import...\n');
24
24
  const tick = performance.now();
@@ -14,4 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("."), exports);
17
+ __exportStar(require("./build-pcf"), exports);
18
+ __exportStar(require("./import-pcf"), exports);
19
+ __exportStar(require("./init-pcf"), exports);
20
+ __exportStar(require("./upgrade-pcf"), exports);
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.run = run;
6
+ exports.runInit = runInit;
7
7
  const child_process_1 = require("child_process");
8
8
  const path_1 = require("path");
9
9
  const fs_1 = __importDefault(require("fs"));
@@ -22,27 +22,39 @@ function pcfExistsInParent(path) {
22
22
  }
23
23
  throw new Error('PCF project not found.');
24
24
  }
25
- function run(path, name, publisherName, publisherPrefix, verbose) {
25
+ function runInit(path, name, publisherName, publisherPrefix, npm, verbose) {
26
26
  color_logger_1.default.log('[PCF Helper] ' + (0, performanceUtil_1.formatTime)(new Date()) + ' Starting init...\n');
27
27
  const tick = performance.now();
28
28
  path = path !== null && path !== void 0 ? path : process.cwd();
29
+ const initTask = (0, child_process_1.spawnSync)('pac pcf init', ['-ns', publisherPrefix, '-n', name, '-t', 'field', '-fw', 'react', '-o', path, '-npm', npm ? 'true' : 'false'], {
30
+ cwd: process.cwd(),
31
+ stdio: 'inherit',
32
+ shell: true,
33
+ timeout: 1000 * 60 * 5, // 5 minutes
34
+ });
35
+ if (initTask.status !== 0) {
36
+ return (0, performanceUtil_1.handleTaskCompletion)(initTask, 'init', performance.now() - tick, verbose);
37
+ }
29
38
  let pathFiles = fs_1.default.readdirSync(path);
30
39
  let atRoot = pathFiles.some(file => (0, path_1.extname)(file).toLowerCase() === '.pcfproj');
31
40
  const cdsPath = atRoot ? (0, path_1.join)(path, 'Solutions', name) : (0, path_1.join)(path, name);
32
- const initTask = (0, child_process_1.spawnSync)('pac solution init', ['-pn', publisherName, '-pp', publisherPrefix, '-o', cdsPath], {
41
+ color_logger_1.default.log('[PCF Helper] ' + (0, performanceUtil_1.formatTime)(new Date()) + ' Initializing solution...\n');
42
+ const solutionTask = (0, child_process_1.spawnSync)('pac solution init', ['-pn', publisherName, '-pp', publisherPrefix, '-o', cdsPath], {
33
43
  cwd: process.cwd(),
34
44
  stdio: 'inherit',
35
45
  shell: true,
36
46
  timeout: 1000 * 60 * 5, // 5 minutes
37
47
  });
38
- if (initTask.status !== 0) {
39
- return (0, performanceUtil_1.handleTaskCompletion)(initTask, 'init', performance.now() - tick, verbose);
48
+ if (solutionTask.status !== 0) {
49
+ return (0, performanceUtil_1.handleTaskCompletion)(solutionTask, 'init', performance.now() - tick, verbose);
40
50
  }
41
51
  if (!atRoot) {
42
52
  path = pcfExistsInParent(path);
43
53
  }
44
- const packageTask = (0, child_process_1.spawnSync)('pac solution add-reference', ['-p', path], {
45
- cwd: process.cwd(),
54
+ const pcfProjPath = fs_1.default.realpathSync(path);
55
+ color_logger_1.default.log('[PCF Helper] ' + (0, performanceUtil_1.formatTime)(new Date()) + ' Adding solution reference...', pcfProjPath);
56
+ const packageTask = (0, child_process_1.spawnSync)('pac solution add-reference', ['-p', pcfProjPath], {
57
+ cwd: cdsPath,
46
58
  stdio: 'inherit',
47
59
  shell: true,
48
60
  timeout: 1000 * 60 * 5, // 5 minutes
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.run = run;
6
+ exports.runUpgrade = runUpgrade;
7
7
  const child_process_1 = require("child_process");
8
8
  const performanceUtil_1 = require("../util/performanceUtil");
9
9
  const color_logger_1 = __importDefault(require("@tywalk/color-logger"));
@@ -15,7 +15,7 @@ const color_logger_1 = __importDefault(require("@tywalk/color-logger"));
15
15
  *
16
16
  * @returns {number} The exit code of the spawned process.
17
17
  */
18
- function run(path, verbose) {
18
+ function runUpgrade(path, verbose) {
19
19
  color_logger_1.default.log('[PCF Helper] ' + (0, performanceUtil_1.formatTime)(new Date()) + ' Starting upgrade...\n');
20
20
  const tick = performance.now();
21
21
  const task = (0, child_process_1.spawnSync)(`pac solution version -s Solution -sp ${path} && pac pcf version -s Manifest && npm version patch --no-git-tag-version`, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tywalk/pcf-helper",
3
- "version": "1.4.18",
3
+ "version": "1.4.21",
4
4
  "description": "Command line helper for building and publishing PCF controls to Dataverse.",
5
5
  "main": "dist/index.js",
6
6
  "types": "./types/",
@@ -15,7 +15,7 @@
15
15
  "test": "jest",
16
16
  "build": "tsc",
17
17
  "upgrade": "npm version patch --no-git-tag-version",
18
- "ready": "npm run upgrade && npm run build"
18
+ "ready": "npm run upgrade"
19
19
  },
20
20
  "keywords": [
21
21
  "pcf"
@@ -0,0 +1 @@
1
+ export {};
@@ -6,5 +6,5 @@
6
6
  *
7
7
  * @returns {number} The exit code of the spawned process.
8
8
  */
9
- declare function run(path: string, verbose: boolean): number;
10
- export { run };
9
+ declare function runBuild(path: string, verbose: boolean): number;
10
+ export { runBuild };
@@ -7,5 +7,5 @@
7
7
  *
8
8
  * @returns {number} The exit status of the import process.
9
9
  */
10
- declare function run(path: string, env: string, verbose?: boolean): number;
11
- export { run };
10
+ declare function runImport(path: string, env: string, verbose?: boolean): number;
11
+ export { runImport };
@@ -1 +1,4 @@
1
- export * from '.';
1
+ export * from './build-pcf';
2
+ export * from './import-pcf';
3
+ export * from './init-pcf';
4
+ export * from './upgrade-pcf';
@@ -1,2 +1,2 @@
1
- declare function run(path: string, name: string, publisherName: string, publisherPrefix: string, verbose: boolean): number;
2
- export { run };
1
+ declare function runInit(path: string, name: string, publisherName: string, publisherPrefix: string, npm: boolean, verbose: boolean): number;
2
+ export { runInit };
@@ -6,5 +6,5 @@
6
6
  *
7
7
  * @returns {number} The exit code of the spawned process.
8
8
  */
9
- declare function run(path: string, verbose?: boolean): number;
10
- export { run };
9
+ declare function runUpgrade(path: string, verbose?: boolean): number;
10
+ export { runUpgrade };