@tywalk/pcf-helper 1.4.20 → 1.4.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const child_process_1 = require("child_process");
|
|
4
|
+
const package_json_1 = require("../package.json");
|
|
5
|
+
test('init displays version', (done) => {
|
|
6
|
+
const task = (0, child_process_1.spawn)('node', ['./dist/bin/init.js', '-v']);
|
|
7
|
+
let output = '';
|
|
8
|
+
task.stdout.on('data', (data) => {
|
|
9
|
+
output += data.toString();
|
|
10
|
+
});
|
|
11
|
+
task.on('close', (code) => {
|
|
12
|
+
console.log(output);
|
|
13
|
+
expect(output).toContain(package_json_1.version);
|
|
14
|
+
expect(code).toBe(0);
|
|
15
|
+
done();
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
test('init errors if no path is provided', (done) => {
|
|
19
|
+
const task = (0, child_process_1.spawn)('node', ['./dist/bin/init.js', '-p']);
|
|
20
|
+
let output = '';
|
|
21
|
+
task.stdout.on('data', (data) => {
|
|
22
|
+
output += data.toString();
|
|
23
|
+
});
|
|
24
|
+
task.stderr.on('data', (data) => {
|
|
25
|
+
console.error(`stderr: ${data}`);
|
|
26
|
+
});
|
|
27
|
+
task.on('close', (code) => {
|
|
28
|
+
console.log(output);
|
|
29
|
+
expect(code).toBe(1);
|
|
30
|
+
done();
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
// test('init creates pcf', () => {
|
|
34
|
+
// logger.setDebug(true);
|
|
35
|
+
// const result = runInit('./tests', 'test', 'testpb', 'tb', false, true);
|
|
36
|
+
// expect(result).toBe(0);
|
|
37
|
+
// });
|
package/dist/bin/init.js
CHANGED
|
@@ -36,7 +36,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
36
36
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
37
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
38
|
};
|
|
39
|
-
var _a, _b, _c, _d, _e;
|
|
39
|
+
var _a, _b, _c, _d, _e, _f;
|
|
40
40
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
41
|
const task = __importStar(require("../tasks/init-pcf"));
|
|
42
42
|
const package_json_1 = require("../package.json");
|
|
@@ -81,4 +81,10 @@ if (typeof pathArgument !== 'undefined') {
|
|
|
81
81
|
const pathIndex = args.indexOf(pathArgument) + 1;
|
|
82
82
|
path = (_e = args.at(pathIndex)) !== null && _e !== void 0 ? _e : '';
|
|
83
83
|
}
|
|
84
|
-
|
|
84
|
+
let npm = '';
|
|
85
|
+
const npmArgument = args.find(a => ['-npm', '--run-npm-install'].includes(a));
|
|
86
|
+
if (typeof npmArgument !== 'undefined') {
|
|
87
|
+
const pathIndex = args.indexOf(npmArgument) + 1;
|
|
88
|
+
npm = (_f = args.at(pathIndex)) !== null && _f !== void 0 ? _f : '';
|
|
89
|
+
}
|
|
90
|
+
task.runInit(path, name, publisherName, publisherPrefix, npm === 'true', verboseArgument !== undefined);
|
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.21",
|
|
4
4
|
"description": "Command line helper for building and publishing PCF controls to Dataverse.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "./types/",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"test": "jest",
|
|
16
16
|
"build": "tsc",
|
|
17
17
|
"upgrade": "npm version patch --no-git-tag-version",
|
|
18
|
-
"ready": "npm run upgrade
|
|
18
|
+
"ready": "npm run upgrade"
|
|
19
19
|
},
|
|
20
20
|
"keywords": [
|
|
21
21
|
"pcf"
|
package/dist/tasks/init-pcf.js
CHANGED
|
@@ -22,27 +22,39 @@ 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');
|
|
31
40
|
const cdsPath = atRoot ? (0, path_1.join)(path, 'Solutions', name) : (0, path_1.join)(path, name);
|
|
32
|
-
|
|
41
|
+
color_logger_1.default.log('[PCF Helper] ' + (0, performanceUtil_1.formatTime)(new Date()) + ' Initializing solution...\n');
|
|
42
|
+
const solutionTask = (0, child_process_1.spawnSync)('pac solution init', ['-pn', publisherName, '-pp', publisherPrefix, '-o', cdsPath], {
|
|
33
43
|
cwd: process.cwd(),
|
|
34
44
|
stdio: 'inherit',
|
|
35
45
|
shell: true,
|
|
36
46
|
timeout: 1000 * 60 * 5, // 5 minutes
|
|
37
47
|
});
|
|
38
|
-
if (
|
|
39
|
-
return (0, performanceUtil_1.handleTaskCompletion)(
|
|
48
|
+
if (solutionTask.status !== 0) {
|
|
49
|
+
return (0, performanceUtil_1.handleTaskCompletion)(solutionTask, 'init', performance.now() - tick, verbose);
|
|
40
50
|
}
|
|
41
51
|
if (!atRoot) {
|
|
42
52
|
path = pcfExistsInParent(path);
|
|
43
53
|
}
|
|
44
|
-
const
|
|
45
|
-
|
|
54
|
+
const pcfProjPath = fs_1.default.realpathSync(path);
|
|
55
|
+
color_logger_1.default.log('[PCF Helper] ' + (0, performanceUtil_1.formatTime)(new Date()) + ' Adding solution reference...', pcfProjPath);
|
|
56
|
+
const packageTask = (0, child_process_1.spawnSync)('pac solution add-reference', ['-p', pcfProjPath], {
|
|
57
|
+
cwd: cdsPath,
|
|
46
58
|
stdio: 'inherit',
|
|
47
59
|
shell: true,
|
|
48
60
|
timeout: 1000 * 60 * 5, // 5 minutes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tywalk/pcf-helper",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.21",
|
|
4
4
|
"description": "Command line helper for building and publishing PCF controls to Dataverse.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "./types/",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"test": "jest",
|
|
16
16
|
"build": "tsc",
|
|
17
17
|
"upgrade": "npm version patch --no-git-tag-version",
|
|
18
|
-
"ready": "npm run upgrade
|
|
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 };
|