@tywalk/pcf-helper 1.4.20 → 1.4.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/__tests__/pcf-helper-init.test.js +37 -0
- package/dist/bin/build.js +2 -7
- package/dist/bin/deploy.js +3 -7
- package/dist/bin/import.js +4 -14
- package/dist/bin/init.js +8 -27
- package/dist/bin/upgrade.js +2 -7
- package/dist/package.json +2 -2
- package/dist/tasks/init-pcf.js +19 -6
- package/dist/util/argumentUtil.js +20 -0
- package/package.json +2 -2
- package/types/__tests__/pcf-helper-init.test.d.ts +1 -0
- package/types/tasks/init-pcf.d.ts +1 -1
- package/types/util/argumentUtil.d.ts +2 -0
|
@@ -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
|
@@ -41,6 +41,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
41
41
|
const task = __importStar(require("../tasks/build-pcf"));
|
|
42
42
|
const package_json_1 = require("../package.json");
|
|
43
43
|
const color_logger_1 = __importDefault(require("@tywalk/color-logger"));
|
|
44
|
+
const argumentUtil_1 = require("../util/argumentUtil");
|
|
44
45
|
const [, , ...args] = process.argv;
|
|
45
46
|
const commandArgument = (_b = (_a = args.at(0)) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== null && _b !== void 0 ? _b : '';
|
|
46
47
|
if (['-v', '--version'].includes(commandArgument)) {
|
|
@@ -52,13 +53,7 @@ if (typeof verboseArgument !== 'undefined') {
|
|
|
52
53
|
color_logger_1.default.setDebug(true);
|
|
53
54
|
}
|
|
54
55
|
color_logger_1.default.log('PCF Helper version', package_json_1.version);
|
|
55
|
-
const
|
|
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);
|
|
56
|
+
const path = (0, argumentUtil_1.getArgValue)(args, ['-p', '--path']);
|
|
62
57
|
if (typeof path === 'undefined') {
|
|
63
58
|
color_logger_1.default.error('Path argument is required. Use --path to specify the path to solution folder.');
|
|
64
59
|
process.exit(1);
|
package/dist/bin/deploy.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
|
|
39
|
+
var _a, _b, _c;
|
|
40
40
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
41
|
const upgradeTask = __importStar(require("../tasks/upgrade-pcf"));
|
|
42
42
|
const buildTask = __importStar(require("../tasks/build-pcf"));
|
|
@@ -44,6 +44,7 @@ const importTask = __importStar(require("../tasks/import-pcf"));
|
|
|
44
44
|
const performanceUtil_1 = require("../util/performanceUtil");
|
|
45
45
|
const package_json_1 = require("../package.json");
|
|
46
46
|
const color_logger_1 = __importDefault(require("@tywalk/color-logger"));
|
|
47
|
+
const argumentUtil_1 = require("../util/argumentUtil");
|
|
47
48
|
const [, , ...args] = process.argv;
|
|
48
49
|
const commandArgument = (_b = (_a = args.at(0)) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== null && _b !== void 0 ? _b : '';
|
|
49
50
|
if (['-v', '--version'].includes(commandArgument)) {
|
|
@@ -67,12 +68,7 @@ if (typeof path === 'undefined') {
|
|
|
67
68
|
process.exit(1);
|
|
68
69
|
}
|
|
69
70
|
const tick = performance.now();
|
|
70
|
-
const
|
|
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
|
-
}
|
|
71
|
+
const env = (_c = (0, argumentUtil_1.getArgValue)(args, ['-env', '--environment'])) !== null && _c !== void 0 ? _c : '';
|
|
76
72
|
function executeTasks() {
|
|
77
73
|
const upgradeResult = upgradeTask.runUpgrade(path, typeof verboseArgument !== 'undefined');
|
|
78
74
|
if (upgradeResult === 1)
|
package/dist/bin/import.js
CHANGED
|
@@ -36,11 +36,12 @@ 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
|
|
39
|
+
var _a, _b, _c;
|
|
40
40
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
41
|
const task = __importStar(require("../tasks/import-pcf"));
|
|
42
42
|
const package_json_1 = require("../package.json");
|
|
43
43
|
const color_logger_1 = __importDefault(require("@tywalk/color-logger"));
|
|
44
|
+
const argumentUtil_1 = require("../util/argumentUtil");
|
|
44
45
|
const [, , ...args] = process.argv;
|
|
45
46
|
const commandArgument = (_b = (_a = args.at(0)) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== null && _b !== void 0 ? _b : '';
|
|
46
47
|
if (['-v', '--version'].includes(commandArgument)) {
|
|
@@ -52,21 +53,10 @@ if (typeof verboseArgument !== 'undefined') {
|
|
|
52
53
|
color_logger_1.default.setDebug(true);
|
|
53
54
|
}
|
|
54
55
|
color_logger_1.default.log('PCF Helper version', package_json_1.version);
|
|
55
|
-
const
|
|
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);
|
|
56
|
+
const path = (0, argumentUtil_1.getArgValue)(args, ['-p', '--path']);
|
|
62
57
|
if (typeof path === 'undefined') {
|
|
63
58
|
color_logger_1.default.error('Path argument is required. Use --path to specify the path to solution folder.');
|
|
64
59
|
process.exit(1);
|
|
65
60
|
}
|
|
66
|
-
const
|
|
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
|
-
}
|
|
61
|
+
const env = (_c = (0, argumentUtil_1.getArgValue)(args, ['-env', '--environment'])) !== null && _c !== void 0 ? _c : '';
|
|
72
62
|
task.runImport(path, env);
|
package/dist/bin/init.js
CHANGED
|
@@ -41,6 +41,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
41
41
|
const task = __importStar(require("../tasks/init-pcf"));
|
|
42
42
|
const package_json_1 = require("../package.json");
|
|
43
43
|
const color_logger_1 = __importDefault(require("@tywalk/color-logger"));
|
|
44
|
+
const argumentUtil_1 = require("../util/argumentUtil");
|
|
44
45
|
const [, , ...args] = process.argv;
|
|
45
46
|
const commandArgument = (_b = (_a = args.at(0)) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== null && _b !== void 0 ? _b : '';
|
|
46
47
|
if (['-v', '--version'].includes(commandArgument)) {
|
|
@@ -52,33 +53,13 @@ if (typeof verboseArgument !== 'undefined') {
|
|
|
52
53
|
color_logger_1.default.setDebug(true);
|
|
53
54
|
}
|
|
54
55
|
color_logger_1.default.log('PCF Helper version', package_json_1.version);
|
|
55
|
-
const
|
|
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);
|
|
56
|
+
const name = (0, argumentUtil_1.getArgValue)(args, ['-n', '--name']);
|
|
62
57
|
if (typeof name === 'undefined') {
|
|
63
|
-
color_logger_1.default.error('
|
|
58
|
+
color_logger_1.default.error('Name argument is required. Use --name to specify the name of the PCF control.');
|
|
64
59
|
process.exit(1);
|
|
65
60
|
}
|
|
66
|
-
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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.runInit(path, name, publisherName, publisherPrefix, verboseArgument !== undefined);
|
|
61
|
+
const publisherName = (_c = (0, argumentUtil_1.getArgValue)(args, ['-pn', '--publisher-name'])) !== null && _c !== void 0 ? _c : '';
|
|
62
|
+
const publisherPrefix = (_d = (0, argumentUtil_1.getArgValue)(args, ['-pp', '--publisher-prefix'])) !== null && _d !== void 0 ? _d : '';
|
|
63
|
+
const path = (_e = (0, argumentUtil_1.getArgValue)(args, ['-p', '--path'])) !== null && _e !== void 0 ? _e : '';
|
|
64
|
+
const npm = (0, argumentUtil_1.getArgValue)(args, ['-npm', '--run-npm-install'], 'true');
|
|
65
|
+
task.runInit(path, name, publisherName, publisherPrefix, npm === 'true', verboseArgument !== undefined);
|
package/dist/bin/upgrade.js
CHANGED
|
@@ -41,6 +41,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
41
41
|
const task = __importStar(require("../tasks/upgrade-pcf"));
|
|
42
42
|
const package_json_1 = require("../package.json");
|
|
43
43
|
const color_logger_1 = __importDefault(require("@tywalk/color-logger"));
|
|
44
|
+
const argumentUtil_1 = require("../util/argumentUtil");
|
|
44
45
|
const [, , ...args] = process.argv;
|
|
45
46
|
const commandArgument = (_b = (_a = args.at(0)) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== null && _b !== void 0 ? _b : '';
|
|
46
47
|
if (['-v', '--version'].includes(commandArgument)) {
|
|
@@ -52,13 +53,7 @@ if (typeof verboseArgument !== 'undefined') {
|
|
|
52
53
|
color_logger_1.default.setDebug(true);
|
|
53
54
|
}
|
|
54
55
|
color_logger_1.default.log('PCF Helper version', package_json_1.version);
|
|
55
|
-
const
|
|
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);
|
|
56
|
+
const path = (0, argumentUtil_1.getArgValue)(args, ['-p', '--path']);
|
|
62
57
|
if (typeof path === 'undefined') {
|
|
63
58
|
color_logger_1.default.error('Path argument is required. Use --path to specify the path to solution folder.');
|
|
64
59
|
process.exit(1);
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tywalk/pcf-helper",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.22",
|
|
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
|
|
18
|
+
"ready": "npm run upgrade"
|
|
19
19
|
},
|
|
20
20
|
"keywords": [
|
|
21
21
|
"pcf"
|
package/dist/tasks/init-pcf.js
CHANGED
|
@@ -22,27 +22,40 @@ function pcfExistsInParent(path) {
|
|
|
22
22
|
}
|
|
23
23
|
throw new Error('PCF project not found.');
|
|
24
24
|
}
|
|
25
|
-
function runInit(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');
|
|
40
|
+
name += 'PCF'; // Prevent cdsproj from conflicting with pcfproj
|
|
31
41
|
const cdsPath = atRoot ? (0, path_1.join)(path, 'Solutions', name) : (0, path_1.join)(path, name);
|
|
32
|
-
|
|
42
|
+
color_logger_1.default.log('[PCF Helper] ' + (0, performanceUtil_1.formatTime)(new Date()) + ' Initializing solution...\n');
|
|
43
|
+
const solutionTask = (0, child_process_1.spawnSync)('pac solution init', ['-pn', publisherName, '-pp', publisherPrefix, '-o', cdsPath], {
|
|
33
44
|
cwd: process.cwd(),
|
|
34
45
|
stdio: 'inherit',
|
|
35
46
|
shell: true,
|
|
36
47
|
timeout: 1000 * 60 * 5, // 5 minutes
|
|
37
48
|
});
|
|
38
|
-
if (
|
|
39
|
-
return (0, performanceUtil_1.handleTaskCompletion)(
|
|
49
|
+
if (solutionTask.status !== 0) {
|
|
50
|
+
return (0, performanceUtil_1.handleTaskCompletion)(solutionTask, 'init', performance.now() - tick, verbose);
|
|
40
51
|
}
|
|
41
52
|
if (!atRoot) {
|
|
42
53
|
path = pcfExistsInParent(path);
|
|
43
54
|
}
|
|
44
|
-
const
|
|
45
|
-
|
|
55
|
+
const pcfProjPath = fs_1.default.realpathSync(path);
|
|
56
|
+
color_logger_1.default.log('[PCF Helper] ' + (0, performanceUtil_1.formatTime)(new Date()) + ' Adding solution reference...', pcfProjPath);
|
|
57
|
+
const packageTask = (0, child_process_1.spawnSync)('pac solution add-reference', ['-p', pcfProjPath], {
|
|
58
|
+
cwd: cdsPath,
|
|
46
59
|
stdio: 'inherit',
|
|
47
60
|
shell: true,
|
|
48
61
|
timeout: 1000 * 60 * 5, // 5 minutes
|
|
@@ -0,0 +1,20 @@
|
|
|
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, defaultIfExists) {
|
|
13
|
+
var _a;
|
|
14
|
+
const arg = args.find(a => argOpts.includes(a));
|
|
15
|
+
if (typeof arg === 'undefined') {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
const argIndex = args.indexOf(arg) + 1;
|
|
19
|
+
return (_a = args.at(argIndex)) !== null && _a !== void 0 ? _a : defaultIfExists;
|
|
20
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tywalk/pcf-helper",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.22",
|
|
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
|
|
18
|
+
"ready": "npm run upgrade"
|
|
19
19
|
},
|
|
20
20
|
"keywords": [
|
|
21
21
|
"pcf"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare function runInit(path: string, name: string, publisherName: string, publisherPrefix: string, verbose: boolean): number;
|
|
1
|
+
declare function runInit(path: string, name: string, publisherName: string, publisherPrefix: string, npm: boolean, verbose: boolean): number;
|
|
2
2
|
export { runInit };
|