@tywalk/pcf-helper 1.4.15 → 1.4.16

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,35 @@
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('build displays version', (done) => {
6
+ const task = (0, child_process_1.spawn)('node', ['./dist/bin/build.js', '-v']);
7
+ let output = '';
8
+ task.stdout.on('data', (data) => {
9
+ output += data.toString();
10
+ });
11
+ task.stderr.on('data', (data) => {
12
+ console.error(`stderr: ${data}`);
13
+ });
14
+ task.on('close', (code) => {
15
+ console.log(output);
16
+ expect(output).toContain(package_json_1.version);
17
+ expect(code).toBe(0);
18
+ done();
19
+ });
20
+ });
21
+ test('build errors if no path is provided', (done) => {
22
+ const task = (0, child_process_1.spawn)('node', ['./dist/bin/build.js', '-p']);
23
+ let output = '';
24
+ task.stdout.on('data', (data) => {
25
+ output += data.toString();
26
+ });
27
+ task.stderr.on('data', (data) => {
28
+ console.error(`stderr: ${data}`);
29
+ });
30
+ task.on('close', (code) => {
31
+ console.log(output);
32
+ expect(code).toBe(1);
33
+ done();
34
+ });
35
+ });
@@ -0,0 +1,35 @@
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('deploy displays version', (done) => {
6
+ const task = (0, child_process_1.spawn)('node', ['./dist/bin/deploy.js', '-v']);
7
+ let output = '';
8
+ task.stdout.on('data', (data) => {
9
+ output += data.toString();
10
+ });
11
+ task.stderr.on('data', (data) => {
12
+ console.error(`stderr: ${data}`);
13
+ });
14
+ task.on('close', (code) => {
15
+ console.log(output);
16
+ expect(output).toContain(package_json_1.version);
17
+ expect(code).toBe(0);
18
+ done();
19
+ });
20
+ });
21
+ test('deploy errors if no path is provided', (done) => {
22
+ const task = (0, child_process_1.spawn)('node', ['./dist/bin/deploy.js', '-p']);
23
+ let output = '';
24
+ task.stdout.on('data', (data) => {
25
+ output += data.toString();
26
+ });
27
+ task.stderr.on('data', (data) => {
28
+ console.error(`stderr: ${data}`);
29
+ });
30
+ task.on('close', (code) => {
31
+ console.log(output);
32
+ expect(code).toBe(1);
33
+ done();
34
+ });
35
+ });
@@ -0,0 +1,32 @@
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('import displays version', (done) => {
6
+ const task = (0, child_process_1.spawn)('node', ['./dist/bin/import.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('import errors if no path is provided', (done) => {
19
+ const task = (0, child_process_1.spawn)('node', ['./dist/bin/import.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
+ });
@@ -0,0 +1,32 @@
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('upgrade displays version', (done) => {
6
+ const task = (0, child_process_1.spawn)('node', ['./dist/bin/upgrade.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('upgrade errors if no path is provided', (done) => {
19
+ const task = (0, child_process_1.spawn)('node', ['./dist/bin/upgrade.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
+ });
@@ -0,0 +1,66 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
36
+ var __importDefault = (this && this.__importDefault) || function (mod) {
37
+ return (mod && mod.__esModule) ? mod : { "default": mod };
38
+ };
39
+ var _a, _b;
40
+ Object.defineProperty(exports, "__esModule", { value: true });
41
+ const task = __importStar(require("../tasks/build-pcf"));
42
+ const package_json_1 = require("../package.json");
43
+ const color_logger_1 = __importDefault(require("@tywalk/color-logger"));
44
+ const [, , ...args] = process.argv;
45
+ const commandArgument = (_b = (_a = args.at(0)) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== null && _b !== void 0 ? _b : '';
46
+ if (['-v', '--version'].includes(commandArgument)) {
47
+ console.log('v%s', package_json_1.version);
48
+ process.exit(0);
49
+ }
50
+ const verboseArgument = args.find(a => ['-v', '--verbose'].includes(a));
51
+ if (typeof verboseArgument !== 'undefined') {
52
+ color_logger_1.default.setDebug(true);
53
+ }
54
+ color_logger_1.default.log('PCF Helper version', package_json_1.version);
55
+ const pathArgument = args.find(a => ['-p', '--path'].includes(a));
56
+ if (typeof pathArgument === 'undefined') {
57
+ color_logger_1.default.error('Path argument is required. Use --path to specify the path to solution folder.');
58
+ process.exit(1);
59
+ }
60
+ const pathIndex = args.indexOf(pathArgument) + 1;
61
+ const path = args.at(pathIndex);
62
+ if (typeof path === 'undefined') {
63
+ color_logger_1.default.error('Path argument is required. Use --path to specify the path to solution folder.');
64
+ process.exit(1);
65
+ }
66
+ task.run(path, verboseArgument !== undefined);
@@ -0,0 +1,103 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
36
+ var __importDefault = (this && this.__importDefault) || function (mod) {
37
+ return (mod && mod.__esModule) ? mod : { "default": mod };
38
+ };
39
+ var _a, _b, _c, _d;
40
+ Object.defineProperty(exports, "__esModule", { value: true });
41
+ const upgradeTask = __importStar(require("../tasks/upgrade-pcf"));
42
+ const buildTask = __importStar(require("../tasks/build-pcf"));
43
+ const importTask = __importStar(require("../tasks/import-pcf"));
44
+ const performanceUtil_1 = require("../util/performanceUtil");
45
+ const package_json_1 = require("../package.json");
46
+ const color_logger_1 = __importDefault(require("@tywalk/color-logger"));
47
+ const [, , ...args] = process.argv;
48
+ const commandArgument = (_b = (_a = args.at(0)) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== null && _b !== void 0 ? _b : '';
49
+ if (['-v', '--version'].includes(commandArgument)) {
50
+ console.log('v%s', package_json_1.version);
51
+ process.exit(0);
52
+ }
53
+ const verboseArgument = args.find(a => ['-v', '--verbose'].includes(a));
54
+ if (typeof verboseArgument !== 'undefined') {
55
+ color_logger_1.default.setDebug(true);
56
+ }
57
+ color_logger_1.default.log('PCF Helper version', package_json_1.version);
58
+ const pathArgument = args.find(a => ['-p', '--path'].includes(a));
59
+ if (typeof pathArgument === 'undefined') {
60
+ color_logger_1.default.error('Path argument is required. Use --path to specify the path to solution folder.');
61
+ process.exit(1);
62
+ }
63
+ const pathIndex = args.indexOf(pathArgument) + 1;
64
+ const path = args.at(pathIndex);
65
+ if (typeof path === 'undefined') {
66
+ color_logger_1.default.error('Path argument is required. Use --path to specify the path to solution folder.');
67
+ process.exit(1);
68
+ }
69
+ const tick = performance.now();
70
+ const envArgument = (_c = args.find(a => ['-env', '--environment'].includes(a))) !== null && _c !== void 0 ? _c : '';
71
+ let envIndex = args.indexOf(envArgument) + 1;
72
+ let env = '';
73
+ if (envIndex > 0) {
74
+ env = (_d = args.at(envIndex)) !== null && _d !== void 0 ? _d : '';
75
+ }
76
+ function executeTasks() {
77
+ const upgradeResult = upgradeTask.run(path, typeof verboseArgument !== 'undefined');
78
+ if (upgradeResult === 1)
79
+ return 1;
80
+ const buildResult = buildTask.run(path, typeof verboseArgument !== 'undefined');
81
+ if (buildResult === 1)
82
+ return 1;
83
+ const importResult = importTask.run(path, env, typeof verboseArgument !== 'undefined');
84
+ if (importResult === 1)
85
+ return 1;
86
+ return 0;
87
+ }
88
+ var result = 0;
89
+ try {
90
+ result = executeTasks();
91
+ if (result === 0) {
92
+ color_logger_1.default.log('Deploy complete!');
93
+ }
94
+ }
95
+ catch (e) {
96
+ color_logger_1.default.error('One or more tasks failed while deploying: ', (e && e.message) || 'unkown error');
97
+ result = 1;
98
+ }
99
+ finally {
100
+ const tock = performance.now();
101
+ color_logger_1.default.log((0, performanceUtil_1.formatMsToSec)('Deploy finished in %is.', tock - tick));
102
+ }
103
+ process.exit(result);
@@ -0,0 +1,72 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
36
+ var __importDefault = (this && this.__importDefault) || function (mod) {
37
+ return (mod && mod.__esModule) ? mod : { "default": mod };
38
+ };
39
+ var _a, _b, _c, _d;
40
+ Object.defineProperty(exports, "__esModule", { value: true });
41
+ const task = __importStar(require("../tasks/import-pcf"));
42
+ const package_json_1 = require("../package.json");
43
+ const color_logger_1 = __importDefault(require("@tywalk/color-logger"));
44
+ const [, , ...args] = process.argv;
45
+ const commandArgument = (_b = (_a = args.at(0)) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== null && _b !== void 0 ? _b : '';
46
+ if (['-v', '--version'].includes(commandArgument)) {
47
+ console.log('v%s', package_json_1.version);
48
+ process.exit(0);
49
+ }
50
+ const verboseArgument = args.find(a => ['-v', '--verbose'].includes(a));
51
+ if (typeof verboseArgument !== 'undefined') {
52
+ color_logger_1.default.setDebug(true);
53
+ }
54
+ color_logger_1.default.log('PCF Helper version', package_json_1.version);
55
+ const pathArgument = args.find(a => ['-p', '--path'].includes(a));
56
+ if (typeof pathArgument === 'undefined') {
57
+ color_logger_1.default.error('Path argument is required. Use --path to specify the path to solution folder.');
58
+ process.exit(1);
59
+ }
60
+ const pathIndex = args.indexOf(pathArgument) + 1;
61
+ const path = args.at(pathIndex);
62
+ if (typeof path === 'undefined') {
63
+ color_logger_1.default.error('Path argument is required. Use --path to specify the path to solution folder.');
64
+ process.exit(1);
65
+ }
66
+ const envArgument = (_c = args.find(a => ['-env', '--environment'].includes(a))) !== null && _c !== void 0 ? _c : '';
67
+ let envIndex = args.indexOf(envArgument) + 1;
68
+ let env = '';
69
+ if (envIndex > 0) {
70
+ env = (_d = args.at(envIndex)) !== null && _d !== void 0 ? _d : '';
71
+ }
72
+ task.run(path, env);
@@ -0,0 +1,84 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
36
+ var __importDefault = (this && this.__importDefault) || function (mod) {
37
+ return (mod && mod.__esModule) ? mod : { "default": mod };
38
+ };
39
+ var _a, _b, _c, _d, _e;
40
+ Object.defineProperty(exports, "__esModule", { value: true });
41
+ const task = __importStar(require("../tasks/init-pcf"));
42
+ const package_json_1 = require("../package.json");
43
+ const color_logger_1 = __importDefault(require("@tywalk/color-logger"));
44
+ const [, , ...args] = process.argv;
45
+ const commandArgument = (_b = (_a = args.at(0)) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== null && _b !== void 0 ? _b : '';
46
+ if (['-v', '--version'].includes(commandArgument)) {
47
+ console.log('v%s', package_json_1.version);
48
+ process.exit(0);
49
+ }
50
+ const verboseArgument = args.find(a => ['-v', '--verbose'].includes(a));
51
+ if (typeof verboseArgument !== 'undefined') {
52
+ color_logger_1.default.setDebug(true);
53
+ }
54
+ color_logger_1.default.log('PCF Helper version', package_json_1.version);
55
+ const nameArgument = args.find(a => ['-n', '--name'].includes(a));
56
+ if (typeof nameArgument === 'undefined') {
57
+ color_logger_1.default.error('Name argument is required. Use --name to specify the name of the control.');
58
+ process.exit(1);
59
+ }
60
+ const nameIndex = args.indexOf(nameArgument) + 1;
61
+ const name = args.at(nameIndex);
62
+ if (typeof name === 'undefined') {
63
+ color_logger_1.default.error('Path argument is required. Use --path to specify the path to solution folder.');
64
+ process.exit(1);
65
+ }
66
+ let publisherName = '';
67
+ const publisherNameArgument = args.find(a => ['-pn', '--publisher-name'].includes(a));
68
+ if (typeof publisherNameArgument !== 'undefined') {
69
+ const publisherNameIndex = args.indexOf(publisherNameArgument) + 1;
70
+ publisherName = (_c = args.at(publisherNameIndex)) !== null && _c !== void 0 ? _c : '';
71
+ }
72
+ let publisherPrefix = '';
73
+ const publisherPrefixArgument = args.find(a => ['-pp', '--publisher-prefix'].includes(a));
74
+ if (typeof publisherPrefixArgument !== 'undefined') {
75
+ const publisherPrefixIndex = args.indexOf(publisherPrefixArgument) + 1;
76
+ publisherPrefix = (_d = args.at(publisherPrefixIndex)) !== null && _d !== void 0 ? _d : '';
77
+ }
78
+ let path = '';
79
+ const pathArgument = args.find(a => ['-p', '--path'].includes(a));
80
+ if (typeof pathArgument !== 'undefined') {
81
+ const pathIndex = args.indexOf(pathArgument) + 1;
82
+ path = (_e = args.at(pathIndex)) !== null && _e !== void 0 ? _e : '';
83
+ }
84
+ task.run(path, name, publisherName, publisherPrefix, verboseArgument !== undefined);
@@ -0,0 +1,66 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
36
+ var __importDefault = (this && this.__importDefault) || function (mod) {
37
+ return (mod && mod.__esModule) ? mod : { "default": mod };
38
+ };
39
+ var _a, _b;
40
+ Object.defineProperty(exports, "__esModule", { value: true });
41
+ const task = __importStar(require("../tasks/upgrade-pcf"));
42
+ const package_json_1 = require("../package.json");
43
+ const color_logger_1 = __importDefault(require("@tywalk/color-logger"));
44
+ const [, , ...args] = process.argv;
45
+ const commandArgument = (_b = (_a = args.at(0)) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== null && _b !== void 0 ? _b : '';
46
+ if (['-v', '--version'].includes(commandArgument)) {
47
+ console.log('v%s', package_json_1.version);
48
+ process.exit(0);
49
+ }
50
+ const verboseArgument = args.find(a => ['-v', '--verbose'].includes(a));
51
+ if (typeof verboseArgument !== 'undefined') {
52
+ color_logger_1.default.setDebug(true);
53
+ }
54
+ color_logger_1.default.log('PCF Helper version', package_json_1.version);
55
+ const pathArgument = args.find(a => ['-p', '--path'].includes(a));
56
+ if (typeof pathArgument === 'undefined') {
57
+ color_logger_1.default.error('Path argument is required. Use --path to specify the path to solution folder.');
58
+ process.exit(1);
59
+ }
60
+ const pathIndex = args.indexOf(pathArgument) + 1;
61
+ const path = args.at(pathIndex);
62
+ if (typeof path === 'undefined') {
63
+ color_logger_1.default.error('Path argument is required. Use --path to specify the path to solution folder.');
64
+ process.exit(1);
65
+ }
66
+ task.run(path, verboseArgument !== undefined);
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@tywalk/pcf-helper",
3
+ "version": "1.4.16",
4
+ "description": "Command line helper for building and publishing PCF controls to Dataverse.",
5
+ "types": "./types/",
6
+ "files": [
7
+ "dist",
8
+ "types"
9
+ ],
10
+ "repository": {
11
+ "url": "git+https://github.com/tywalk/pcf-helper.git"
12
+ },
13
+ "scripts": {
14
+ "test": "jest",
15
+ "build": "tsc",
16
+ "upgrade": "npm version patch --no-git-tag-version",
17
+ "ready": "npm run upgrade && npm run build"
18
+ },
19
+ "keywords": [
20
+ "pcf"
21
+ ],
22
+ "author": "tywalk",
23
+ "bin": {
24
+ "pcf-helper-upgrade": "dist/bin/upgrade.js",
25
+ "pcf-helper-build": "dist/bin/build.js",
26
+ "pcf-helper-import": "dist/bin/import.js",
27
+ "pcf-helper-deploy": "dist/bin/deploy.js",
28
+ "pcf-helper-init": "dist/bin/init.js"
29
+ },
30
+ "devDependencies": {
31
+ "@types/jest": "^29.5.14",
32
+ "@types/node": "^22.13.11",
33
+ "@tywalk/color-logger": "^1.0.3",
34
+ "jest": "^29.7.0",
35
+ "ts-jest": "^29.2.6",
36
+ "typescript": "^5.8.2"
37
+ }
38
+ }
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.run = run;
7
+ const child_process_1 = require("child_process");
8
+ const performanceUtil_1 = require("../util/performanceUtil");
9
+ const color_logger_1 = __importDefault(require("@tywalk/color-logger"));
10
+ /**
11
+ * Builds the Power Apps component framework project.
12
+ *
13
+ * @param {string} path The path to the project folder containing the pcfproj.json file.
14
+ * @param {boolean} verbose - If true, additional debug information is logged.
15
+ *
16
+ * @returns {number} The exit code of the spawned process.
17
+ */
18
+ function run(path, verbose) {
19
+ color_logger_1.default.log('[PCF Helper] ' + (0, performanceUtil_1.formatTime)(new Date()) + ' Starting build...\n');
20
+ const tick = performance.now();
21
+ const task = (0, child_process_1.spawnSync)('dotnet build', ['--restore', '-c', 'Release', path], {
22
+ cwd: process.cwd(),
23
+ stdio: 'inherit',
24
+ shell: true,
25
+ timeout: 1000 * 60 * 5 // 5 minutes
26
+ });
27
+ return (0, performanceUtil_1.handleTaskCompletion)(task, 'build', performance.now() - tick, verbose);
28
+ }
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.run = run;
7
+ const child_process_1 = require("child_process");
8
+ const path_1 = require("path");
9
+ const fs_1 = __importDefault(require("fs"));
10
+ const color_logger_1 = __importDefault(require("@tywalk/color-logger"));
11
+ const performanceUtil_1 = require("../util/performanceUtil");
12
+ /**
13
+ * Imports a PCF solution into a specified Dataverse environment.
14
+ *
15
+ * @param {string} path - The path to the solution folder containing the build output.
16
+ * @param {string} env - The environment identifier (GUID or URL) where the solution will be imported.
17
+ * @param {boolean} verbose - If true, additional debug information is logged.
18
+ *
19
+ * @returns {number} The exit status of the import process.
20
+ */
21
+ function run(path, env, verbose) {
22
+ var _a;
23
+ color_logger_1.default.log('[PCF Helper] ' + (0, performanceUtil_1.formatTime)(new Date()) + ' Starting import...\n');
24
+ const tick = performance.now();
25
+ if (!env) {
26
+ color_logger_1.default.warn('Path argument not provided. Assuming active auth profile organization.');
27
+ }
28
+ const zipDirPath = (0, path_1.join)(path, '/bin/release');
29
+ // const zipDirPath = join(path, '');
30
+ const zipDirFiles = fs_1.default.readdirSync(zipDirPath);
31
+ const zipFile = (_a = zipDirFiles.find(file => (0, path_1.extname)(file).toLowerCase() === '.zip')) !== null && _a !== void 0 ? _a : '';
32
+ const zipFilePath = (0, path_1.join)(zipDirPath, zipFile);
33
+ const task = (0, child_process_1.spawnSync)('pac solution import', ['-env', env, '-p', zipFilePath, '-pc'], {
34
+ cwd: process.cwd(),
35
+ stdio: 'inherit',
36
+ shell: true,
37
+ timeout: 1000 * 60 * 5, // 5 minutes
38
+ });
39
+ return (0, performanceUtil_1.handleTaskCompletion)(task, 'import', performance.now() - tick, verbose);
40
+ }
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.run = run;
7
+ const child_process_1 = require("child_process");
8
+ const path_1 = require("path");
9
+ const fs_1 = __importDefault(require("fs"));
10
+ const color_logger_1 = __importDefault(require("@tywalk/color-logger"));
11
+ const performanceUtil_1 = require("../util/performanceUtil");
12
+ function pcfExistsInParent(path) {
13
+ let levels = 0;
14
+ while (levels < 3) {
15
+ let pathFiles = fs_1.default.readdirSync(path);
16
+ let atRoot = pathFiles.some(file => (0, path_1.extname)(file).toLowerCase() === '.pcfproj');
17
+ if (atRoot) {
18
+ return path;
19
+ }
20
+ path = (0, path_1.join)(path, '..');
21
+ levels++;
22
+ }
23
+ throw new Error('PCF project not found.');
24
+ }
25
+ function run(path, name, publisherName, publisherPrefix, verbose) {
26
+ color_logger_1.default.log('[PCF Helper] ' + (0, performanceUtil_1.formatTime)(new Date()) + ' Starting init...\n');
27
+ const tick = performance.now();
28
+ path = path !== null && path !== void 0 ? path : process.cwd();
29
+ let pathFiles = fs_1.default.readdirSync(path);
30
+ let atRoot = pathFiles.some(file => (0, path_1.extname)(file).toLowerCase() === '.pcfproj');
31
+ 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], {
33
+ cwd: process.cwd(),
34
+ stdio: 'inherit',
35
+ shell: true,
36
+ timeout: 1000 * 60 * 5, // 5 minutes
37
+ });
38
+ if (initTask.status !== 0) {
39
+ return (0, performanceUtil_1.handleTaskCompletion)(initTask, 'init', performance.now() - tick, verbose);
40
+ }
41
+ if (!atRoot) {
42
+ path = pcfExistsInParent(path);
43
+ }
44
+ const packageTask = (0, child_process_1.spawnSync)('pac solution add-reference', ['-p', path], {
45
+ cwd: process.cwd(),
46
+ stdio: 'inherit',
47
+ shell: true,
48
+ timeout: 1000 * 60 * 5, // 5 minutes
49
+ });
50
+ return (0, performanceUtil_1.handleTaskCompletion)(packageTask, 'init', performance.now() - tick, verbose);
51
+ }
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.run = run;
7
+ const child_process_1 = require("child_process");
8
+ const performanceUtil_1 = require("../util/performanceUtil");
9
+ const color_logger_1 = __importDefault(require("@tywalk/color-logger"));
10
+ /**
11
+ * Upgrades the Power Apps component framework project.
12
+ *
13
+ * @param {string} path The path to the project folder containing the pcfproj.json file.
14
+ * @param {boolean} verbose - If true, additional debug information is logged.
15
+ *
16
+ * @returns {number} The exit code of the spawned process.
17
+ */
18
+ function run(path, verbose) {
19
+ color_logger_1.default.log('[PCF Helper] ' + (0, performanceUtil_1.formatTime)(new Date()) + ' Starting upgrade...\n');
20
+ const tick = performance.now();
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`, {
22
+ cwd: process.cwd(),
23
+ stdio: 'inherit',
24
+ shell: true,
25
+ timeout: 1000 * 60 // 1 min
26
+ });
27
+ return (0, performanceUtil_1.handleTaskCompletion)(task, 'upgrade', performance.now() - tick, verbose);
28
+ }
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.formatMsToSec = formatMsToSec;
7
+ exports.formatTime = formatTime;
8
+ exports.handleTaskCompletion = handleTaskCompletion;
9
+ const util_1 = __importDefault(require("util"));
10
+ const color_logger_1 = __importDefault(require("@tywalk/color-logger"));
11
+ var formatter = new Intl.DateTimeFormat('en-US', {
12
+ hour: '2-digit',
13
+ minute: '2-digit',
14
+ second: '2-digit',
15
+ hour12: false
16
+ });
17
+ /**
18
+ * Formats a number of milliseconds into seconds.
19
+ *
20
+ * @param {string} format - The string format to use when formatting the number of seconds.
21
+ * @param {number} ms - The number of milliseconds to be formatted.
22
+ *
23
+ * @returns {string} The formatted number of seconds.
24
+ */
25
+ function formatMsToSec(format, ms) {
26
+ const seconds = ms / 1000;
27
+ return util_1.default.format(format, seconds);
28
+ }
29
+ /**
30
+ * Formats a Date object into a human-readable string.
31
+ *
32
+ * @param {Date} date - The date object to be formatted.
33
+ *
34
+ * @returns {string} The formatted string.
35
+ */
36
+ function formatTime(date) {
37
+ return formatter.format(date);
38
+ }
39
+ function handleTaskCompletion(task, name, duration, verbose) {
40
+ var _a;
41
+ if (task.status === 0) {
42
+ color_logger_1.default.success(`[PCF Helper] ${name} complete!`);
43
+ color_logger_1.default.debug(formatMsToSec(`[PCF Helper] ${formatTime(new Date())} ${name} finished in %is.\n`, duration));
44
+ }
45
+ else {
46
+ if (task.error) {
47
+ if (task.signal === 'SIGTERM') {
48
+ color_logger_1.default.error(`[PCF Helper] Unable to complete ${name}. A timeout of 5 minutes was reached.`, task.error.message);
49
+ }
50
+ else {
51
+ color_logger_1.default.error(`[PCF Helper] Unable to complete ${name}:`, task.signal, task.error.message);
52
+ }
53
+ if (verbose) {
54
+ color_logger_1.default.debug('[PCF Helper] Error details:', task.signal, task.error.stack);
55
+ }
56
+ }
57
+ else {
58
+ color_logger_1.default.error(`[PCF Helper] Unable to complete ${name}: One or more errors ocurred.`);
59
+ }
60
+ color_logger_1.default.debug(formatMsToSec(`[PCF Helper] ${formatTime(new Date())} ${name} finished with errors in %is.\n`, duration));
61
+ }
62
+ return (_a = task.status) !== null && _a !== void 0 ? _a : 1;
63
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tywalk/pcf-helper",
3
- "version": "1.4.15",
3
+ "version": "1.4.16",
4
4
  "description": "Command line helper for building and publishing PCF controls to Dataverse.",
5
5
  "types": "./types/",
6
6
  "files": [
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Builds the Power Apps component framework project.
3
+ *
4
+ * @param {string} path The path to the project folder containing the pcfproj.json file.
5
+ * @param {boolean} verbose - If true, additional debug information is logged.
6
+ *
7
+ * @returns {number} The exit code of the spawned process.
8
+ */
9
+ declare function run(path: string, verbose: boolean): number;
10
+ export { run };
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Imports a PCF solution into a specified Dataverse environment.
3
+ *
4
+ * @param {string} path - The path to the solution folder containing the build output.
5
+ * @param {string} env - The environment identifier (GUID or URL) where the solution will be imported.
6
+ * @param {boolean} verbose - If true, additional debug information is logged.
7
+ *
8
+ * @returns {number} The exit status of the import process.
9
+ */
10
+ declare function run(path: string, env: string, verbose?: boolean): number;
11
+ export { run };
@@ -0,0 +1,2 @@
1
+ declare function run(path: string, name: string, publisherName: string, publisherPrefix: string, verbose: boolean): number;
2
+ export { run };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Upgrades the Power Apps component framework project.
3
+ *
4
+ * @param {string} path The path to the project folder containing the pcfproj.json file.
5
+ * @param {boolean} verbose - If true, additional debug information is logged.
6
+ *
7
+ * @returns {number} The exit code of the spawned process.
8
+ */
9
+ declare function run(path: string, verbose?: boolean): number;
10
+ export { run };
@@ -0,0 +1,20 @@
1
+ import { SpawnSyncReturns } from 'child_process';
2
+ /**
3
+ * Formats a number of milliseconds into seconds.
4
+ *
5
+ * @param {string} format - The string format to use when formatting the number of seconds.
6
+ * @param {number} ms - The number of milliseconds to be formatted.
7
+ *
8
+ * @returns {string} The formatted number of seconds.
9
+ */
10
+ declare function formatMsToSec(format: string, ms: number): string;
11
+ /**
12
+ * Formats a Date object into a human-readable string.
13
+ *
14
+ * @param {Date} date - The date object to be formatted.
15
+ *
16
+ * @returns {string} The formatted string.
17
+ */
18
+ declare function formatTime(date: Date): string;
19
+ declare function handleTaskCompletion(task: SpawnSyncReturns<Buffer<ArrayBufferLike>>, name: string, duration: number, verbose?: boolean): number;
20
+ export { formatMsToSec, formatTime, handleTaskCompletion };