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