@tywalk/pcf-helper 1.4.26 → 1.5.1
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/bin/build.js +18 -23
- package/dist/bin/deploy.js +16 -35
- package/dist/bin/import.js +13 -26
- package/dist/bin/init.js +16 -20
- package/dist/bin/session.js +12 -8
- package/dist/bin/upgrade.js +12 -16
- package/dist/package.json +2 -2
- package/dist/tasks/session-pcf.js +17 -26
- package/dist/util/argumentUtil.js +97 -0
- package/package.json +2 -2
- package/types/tasks/session-pcf.d.ts +7 -1
- package/types/util/argumentUtil.d.ts +44 -0
package/dist/bin/build.js
CHANGED
|
@@ -36,34 +36,29 @@ 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;
|
|
40
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
40
|
const task = __importStar(require("../tasks/build-pcf"));
|
|
42
41
|
const package_json_1 = require("../package.json");
|
|
43
42
|
const color_logger_1 = __importDefault(require("@tywalk/color-logger"));
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
color_logger_1.default.error('Timeout argument must be a positive number representing milliseconds.');
|
|
56
|
-
process.exit(1);
|
|
43
|
+
const commander_1 = require("commander");
|
|
44
|
+
const program = new commander_1.Command();
|
|
45
|
+
program
|
|
46
|
+
.name('pcf-helper-build')
|
|
47
|
+
.description('Build PCF controls')
|
|
48
|
+
.version(package_json_1.version, '-v, --version')
|
|
49
|
+
.option('-V, --verbose', 'enable verbose logging')
|
|
50
|
+
.option('-t, --timeout <milliseconds>', 'timeout in milliseconds', (value) => {
|
|
51
|
+
const num = Number(value);
|
|
52
|
+
if (isNaN(num) || num <= 0) {
|
|
53
|
+
throw new Error('Timeout must be a positive number');
|
|
57
54
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
55
|
+
return value;
|
|
56
|
+
})
|
|
57
|
+
.requiredOption('-p, --path <path>', 'path to solution folder')
|
|
58
|
+
.parse();
|
|
59
|
+
const options = program.opts();
|
|
60
|
+
if (options.verbose) {
|
|
61
61
|
color_logger_1.default.setDebug(true);
|
|
62
62
|
}
|
|
63
63
|
color_logger_1.default.log('PCF Helper version', package_json_1.version);
|
|
64
|
-
|
|
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
|
-
task.runBuild(path, verboseArgument !== undefined, typeof timeout !== 'undefined' ? Number(timeout) : undefined);
|
|
64
|
+
task.runBuild(options.path, options.verbose || false, options.timeout ? Number(options.timeout) : undefined);
|
package/dist/bin/deploy.js
CHANGED
|
@@ -36,7 +36,6 @@ 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;
|
|
40
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
40
|
const upgradeTask = __importStar(require("../tasks/upgrade-pcf"));
|
|
42
41
|
const buildTask = __importStar(require("../tasks/build-pcf"));
|
|
@@ -44,47 +43,29 @@ const importTask = __importStar(require("../tasks/import-pcf"));
|
|
|
44
43
|
const performanceUtil_1 = require("../util/performanceUtil");
|
|
45
44
|
const package_json_1 = require("../package.json");
|
|
46
45
|
const color_logger_1 = __importDefault(require("@tywalk/color-logger"));
|
|
46
|
+
const commander_1 = require("commander");
|
|
47
47
|
const argumentUtil_1 = require("../util/argumentUtil");
|
|
48
|
-
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
color_logger_1.default.error('Timeout argument must be a positive number representing milliseconds.');
|
|
59
|
-
process.exit(1);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
const verboseArgument = args.find(a => ['-v', '--verbose'].includes(a));
|
|
63
|
-
if (typeof verboseArgument !== 'undefined') {
|
|
64
|
-
color_logger_1.default.setDebug(true);
|
|
65
|
-
}
|
|
48
|
+
// Apply argument preprocessing for backward compatibility
|
|
49
|
+
const { hadDeprecatedEnv } = (0, argumentUtil_1.applyArgumentPreprocessing)(process.argv);
|
|
50
|
+
const program = new commander_1.Command();
|
|
51
|
+
(0, argumentUtil_1.addPathAndEnvironmentOptions)(program)
|
|
52
|
+
.name('pcf-helper-deploy')
|
|
53
|
+
.description('Deploy PCF controls (runs upgrade, build, and import)')
|
|
54
|
+
.version(package_json_1.version, '-v, --version')
|
|
55
|
+
.parse();
|
|
56
|
+
const options = program.opts();
|
|
57
|
+
(0, argumentUtil_1.setupLogging)(options.verbose);
|
|
66
58
|
color_logger_1.default.log('PCF Helper version', package_json_1.version);
|
|
67
|
-
const
|
|
68
|
-
if (typeof pathArgument === 'undefined') {
|
|
69
|
-
color_logger_1.default.error('Path argument is required. Use --path to specify the path to solution folder.');
|
|
70
|
-
process.exit(1);
|
|
71
|
-
}
|
|
72
|
-
const pathIndex = args.indexOf(pathArgument) + 1;
|
|
73
|
-
const path = args.at(pathIndex);
|
|
74
|
-
if (typeof path === 'undefined') {
|
|
75
|
-
color_logger_1.default.error('Path argument is required. Use --path to specify the path to solution folder.');
|
|
76
|
-
process.exit(1);
|
|
77
|
-
}
|
|
59
|
+
const env = (0, argumentUtil_1.resolveEnvironment)(options, hadDeprecatedEnv);
|
|
78
60
|
const tick = performance.now();
|
|
79
|
-
const env = (_c = (0, argumentUtil_1.getArgValue)(args, ['-env', '--environment'])) !== null && _c !== void 0 ? _c : '';
|
|
80
61
|
function executeTasks() {
|
|
81
|
-
const upgradeResult = upgradeTask.runUpgrade(path,
|
|
62
|
+
const upgradeResult = upgradeTask.runUpgrade(options.path, options.verbose || false);
|
|
82
63
|
if (upgradeResult === 1)
|
|
83
64
|
return 1;
|
|
84
|
-
const buildResult = buildTask.runBuild(path,
|
|
65
|
+
const buildResult = buildTask.runBuild(options.path, options.verbose || false, options.timeout ? Number(options.timeout) : undefined);
|
|
85
66
|
if (buildResult === 1)
|
|
86
67
|
return 1;
|
|
87
|
-
const importResult = importTask.runImport(path, env,
|
|
68
|
+
const importResult = importTask.runImport(options.path, env, options.verbose || false, options.timeout ? Number(options.timeout) : undefined);
|
|
88
69
|
if (importResult === 1)
|
|
89
70
|
return 1;
|
|
90
71
|
return 0;
|
|
@@ -97,7 +78,7 @@ try {
|
|
|
97
78
|
}
|
|
98
79
|
}
|
|
99
80
|
catch (e) {
|
|
100
|
-
color_logger_1.default.error('One or more tasks failed while deploying: ', (e && e.message) || '
|
|
81
|
+
color_logger_1.default.error('One or more tasks failed while deploying: ', (e && e.message) || 'unknown error');
|
|
101
82
|
result = 1;
|
|
102
83
|
}
|
|
103
84
|
finally {
|
package/dist/bin/import.js
CHANGED
|
@@ -36,35 +36,22 @@ 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;
|
|
40
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
40
|
const task = __importStar(require("../tasks/import-pcf"));
|
|
42
41
|
const package_json_1 = require("../package.json");
|
|
43
42
|
const color_logger_1 = __importDefault(require("@tywalk/color-logger"));
|
|
43
|
+
const commander_1 = require("commander");
|
|
44
44
|
const argumentUtil_1 = require("../util/argumentUtil");
|
|
45
|
-
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
color_logger_1.default.error('Timeout argument must be a positive number representing milliseconds.');
|
|
56
|
-
process.exit(1);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
const verboseArgument = args.find(a => ['-v', '--verbose'].includes(a));
|
|
60
|
-
if (typeof verboseArgument !== 'undefined') {
|
|
61
|
-
color_logger_1.default.setDebug(true);
|
|
62
|
-
}
|
|
45
|
+
// Apply argument preprocessing for backward compatibility
|
|
46
|
+
const { hadDeprecatedEnv } = (0, argumentUtil_1.applyArgumentPreprocessing)(process.argv);
|
|
47
|
+
const program = new commander_1.Command();
|
|
48
|
+
(0, argumentUtil_1.addPathAndEnvironmentOptions)(program)
|
|
49
|
+
.name('pcf-helper-import')
|
|
50
|
+
.description('Import PCF controls to Dataverse')
|
|
51
|
+
.version(package_json_1.version, '-v, --version')
|
|
52
|
+
.parse();
|
|
53
|
+
const options = program.opts();
|
|
54
|
+
(0, argumentUtil_1.setupLogging)(options.verbose);
|
|
63
55
|
color_logger_1.default.log('PCF Helper version', package_json_1.version);
|
|
64
|
-
const
|
|
65
|
-
|
|
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 env = (_c = (0, argumentUtil_1.getArgValue)(args, ['-env', '--environment'])) !== null && _c !== void 0 ? _c : '';
|
|
70
|
-
task.runImport(path, env, verboseArgument !== undefined, typeof timeout !== 'undefined' ? Number(timeout) : undefined);
|
|
56
|
+
const env = (0, argumentUtil_1.resolveEnvironment)(options, hadDeprecatedEnv);
|
|
57
|
+
task.runImport(options.path, env, options.verbose || false, options.timeout ? Number(options.timeout) : undefined);
|
package/dist/bin/init.js
CHANGED
|
@@ -36,30 +36,26 @@ 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;
|
|
40
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
40
|
const task = __importStar(require("../tasks/init-pcf"));
|
|
42
41
|
const package_json_1 = require("../package.json");
|
|
43
42
|
const color_logger_1 = __importDefault(require("@tywalk/color-logger"));
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
43
|
+
const commander_1 = require("commander");
|
|
44
|
+
const program = new commander_1.Command();
|
|
45
|
+
program
|
|
46
|
+
.name('pcf-helper-init')
|
|
47
|
+
.description('Initialize a new PCF project')
|
|
48
|
+
.version(package_json_1.version, '-v, --version')
|
|
49
|
+
.option('-V, --verbose', 'enable verbose logging')
|
|
50
|
+
.requiredOption('-n, --name <name>', 'name of the PCF control')
|
|
51
|
+
.option('--publisher-name <publisherName>', 'publisher name')
|
|
52
|
+
.option('--publisher-prefix <publisherPrefix>', 'publisher prefix')
|
|
53
|
+
.option('-p, --path <path>', 'path to create the PCF project')
|
|
54
|
+
.option('--run-npm-install', 'run npm install after initialization', true)
|
|
55
|
+
.parse();
|
|
56
|
+
const options = program.opts();
|
|
57
|
+
if (options.verbose) {
|
|
53
58
|
color_logger_1.default.setDebug(true);
|
|
54
59
|
}
|
|
55
60
|
color_logger_1.default.log('PCF Helper version', package_json_1.version);
|
|
56
|
-
|
|
57
|
-
if (typeof name === 'undefined') {
|
|
58
|
-
color_logger_1.default.error('Name argument is required. Use --name to specify the name of the PCF control.');
|
|
59
|
-
process.exit(1);
|
|
60
|
-
}
|
|
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);
|
|
61
|
+
task.runInit(options.path || '', options.name, options.publisherName || '', options.publisherPrefix || '', options.runNpmInstall !== false, options.verbose || false);
|
package/dist/bin/session.js
CHANGED
|
@@ -43,18 +43,22 @@ const color_logger_1 = __importDefault(require("@tywalk/color-logger"));
|
|
|
43
43
|
const commander_1 = require("commander");
|
|
44
44
|
const program = new commander_1.Command();
|
|
45
45
|
program
|
|
46
|
-
.
|
|
47
|
-
.
|
|
46
|
+
.name('pcf-helper-session')
|
|
47
|
+
.description('Run development session')
|
|
48
|
+
.version(package_json_1.version, '-v, --version')
|
|
49
|
+
.option('-V, --verbose', 'enable verbose logging')
|
|
50
|
+
.option('-u, --url <url>', 'remote environment URL')
|
|
51
|
+
.option('-s, --script <script>', 'remote script to intercept')
|
|
52
|
+
.option('-t, --stylesheet <stylesheet>', 'remote stylesheet to intercept')
|
|
53
|
+
.option('-b, --bundle <path>', 'local bundle path')
|
|
54
|
+
.option('-c, --css <path>', 'local CSS path')
|
|
55
|
+
.option('-f, --config <path>', 'config file path', 'dev-config.json')
|
|
48
56
|
.parse();
|
|
49
57
|
const options = program.opts();
|
|
50
|
-
if (options.version) {
|
|
51
|
-
console.log('v%s', package_json_1.version);
|
|
52
|
-
process.exit(0);
|
|
53
|
-
}
|
|
54
58
|
if (options.verbose) {
|
|
55
|
-
color_logger_1.default.
|
|
59
|
+
color_logger_1.default.setDebug(true);
|
|
56
60
|
color_logger_1.default.debug('Verbose logging enabled');
|
|
57
61
|
}
|
|
58
62
|
color_logger_1.default.log('PCF Helper version', package_json_1.version);
|
|
59
|
-
const config = task.loadConfig();
|
|
63
|
+
const config = task.loadConfig(options.config);
|
|
60
64
|
task.runSession(config.remoteEnvironmentUrl, config.remoteScriptToIntercept, config.remoteStylesheetToIntercept, config.localBundlePath, config.localCssPath);
|
package/dist/bin/upgrade.js
CHANGED
|
@@ -36,26 +36,22 @@ 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;
|
|
40
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
40
|
const task = __importStar(require("../tasks/upgrade-pcf"));
|
|
42
41
|
const package_json_1 = require("../package.json");
|
|
43
42
|
const color_logger_1 = __importDefault(require("@tywalk/color-logger"));
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
43
|
+
const commander_1 = require("commander");
|
|
44
|
+
const program = new commander_1.Command();
|
|
45
|
+
program
|
|
46
|
+
.name('pcf-helper-upgrade')
|
|
47
|
+
.description('Upgrade PCF controls')
|
|
48
|
+
.version(package_json_1.version, '-v, --version')
|
|
49
|
+
.option('-V, --verbose', 'enable verbose logging')
|
|
50
|
+
.requiredOption('-p, --path <path>', 'path to solution folder')
|
|
51
|
+
.parse();
|
|
52
|
+
const options = program.opts();
|
|
53
|
+
if (options.verbose) {
|
|
53
54
|
color_logger_1.default.setDebug(true);
|
|
54
55
|
}
|
|
55
56
|
color_logger_1.default.log('PCF Helper version', package_json_1.version);
|
|
56
|
-
|
|
57
|
-
if (typeof path === 'undefined') {
|
|
58
|
-
color_logger_1.default.error('Path argument is required. Use --path to specify the path to solution folder.');
|
|
59
|
-
process.exit(1);
|
|
60
|
-
}
|
|
61
|
-
task.runUpgrade(path, verboseArgument !== undefined);
|
|
57
|
+
task.runUpgrade(options.path, options.verbose || false);
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tywalk/pcf-helper",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.1",
|
|
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 && npm run build && npm publish --access public"
|
|
19
19
|
},
|
|
20
20
|
"keywords": [
|
|
21
21
|
"pcf"
|
|
@@ -18,37 +18,27 @@ const color_logger_1 = __importDefault(require("@tywalk/color-logger"));
|
|
|
18
18
|
const path_1 = __importDefault(require("path"));
|
|
19
19
|
const fs_1 = __importDefault(require("fs"));
|
|
20
20
|
const playwright_1 = require("playwright");
|
|
21
|
-
|
|
22
|
-
function loadConfig() {
|
|
23
|
-
const program = new commander_1.Command();
|
|
24
|
-
program
|
|
25
|
-
.option('-u, --url <url>', 'remote environment URL')
|
|
26
|
-
.option('-s, --script <script>', 'remote script to intercept')
|
|
27
|
-
.option('-t, --stylesheet <stylesheet>', 'remote stylesheet to intercept')
|
|
28
|
-
.option('-b, --bundle <path>', 'local bundle path')
|
|
29
|
-
.option('-c, --css <path>', 'local CSS path')
|
|
30
|
-
.option('-f, --config <path>', 'config file path', 'dev-config.json')
|
|
31
|
-
.parse();
|
|
32
|
-
const options = program.opts();
|
|
21
|
+
function loadConfig(config) {
|
|
33
22
|
// Load file config if exists
|
|
34
23
|
let fileConfig = {};
|
|
35
|
-
const configPath = path_1.default.join(
|
|
36
|
-
|
|
24
|
+
const configPath = path_1.default.join(process.cwd(), config || 'dev-config.json');
|
|
25
|
+
color_logger_1.default.log(`📁 Looking for config file at: ${configPath}`);
|
|
37
26
|
if (fs_1.default.existsSync(configPath)) {
|
|
38
27
|
fileConfig = JSON.parse(fs_1.default.readFileSync(configPath, 'utf8'));
|
|
39
|
-
|
|
28
|
+
color_logger_1.default.log(`✅ Loaded config file: ${JSON.stringify(fileConfig, null, 2)}`);
|
|
29
|
+
}
|
|
30
|
+
else if (process.env.REMOTE_ENVIRONMENT_URL) {
|
|
31
|
+
color_logger_1.default.warn(`⚠️ Config file not found, using defaults or CLI/env options.`);
|
|
40
32
|
}
|
|
41
33
|
else {
|
|
42
|
-
|
|
34
|
+
return {}; // No config file and no env vars, return empty config to use defaults
|
|
43
35
|
}
|
|
44
36
|
// Get the base URL first
|
|
45
|
-
const remoteEnvironmentUrl =
|
|
46
|
-
process.env.REMOTE_ENVIRONMENT_URL ||
|
|
37
|
+
const remoteEnvironmentUrl = process.env.REMOTE_ENVIRONMENT_URL ||
|
|
47
38
|
fileConfig.remoteEnvironmentUrl ||
|
|
48
39
|
'https://app.your-remote-environment.com';
|
|
49
40
|
// Handle script argument - support both relative paths and full URLs
|
|
50
|
-
let remoteScriptToIntercept =
|
|
51
|
-
process.env.REMOTE_SCRIPT_TO_INTERCEPT ||
|
|
41
|
+
let remoteScriptToIntercept = process.env.REMOTE_SCRIPT_TO_INTERCEPT ||
|
|
52
42
|
fileConfig.remoteScriptToIntercept ||
|
|
53
43
|
'https://app.your-remote-environment.com/static/js/remote-control-bundle.js';
|
|
54
44
|
// If script is a relative path (doesn't start with http/https), combine with base URL
|
|
@@ -61,8 +51,7 @@ function loadConfig() {
|
|
|
61
51
|
: '/' + remoteScriptToIntercept;
|
|
62
52
|
remoteScriptToIntercept = `${baseUrl}${scriptPath}`;
|
|
63
53
|
}
|
|
64
|
-
let remoteStylesheetToIntercept =
|
|
65
|
-
process.env.REMOTE_STYLESHEET_TO_INTERCEPT ||
|
|
54
|
+
let remoteStylesheetToIntercept = process.env.REMOTE_STYLESHEET_TO_INTERCEPT ||
|
|
66
55
|
fileConfig.remoteStylesheetToIntercept ||
|
|
67
56
|
'https://app.your-remote-environment.com/static/css/remote-control-styles.css';
|
|
68
57
|
// If stylesheet is a relative path (doesn't start with http/https), combine with base URL
|
|
@@ -80,17 +69,19 @@ function loadConfig() {
|
|
|
80
69
|
remoteEnvironmentUrl: remoteEnvironmentUrl,
|
|
81
70
|
remoteScriptToIntercept: remoteScriptToIntercept,
|
|
82
71
|
remoteStylesheetToIntercept: remoteStylesheetToIntercept,
|
|
83
|
-
localCssPath:
|
|
84
|
-
process.env.LOCAL_CSS_PATH ||
|
|
72
|
+
localCssPath: process.env.LOCAL_CSS_PATH ||
|
|
85
73
|
fileConfig.localCssPath ||
|
|
86
74
|
path_1.default.join(__dirname, 'dist', 'local-control-styles.css'),
|
|
87
|
-
localBundlePath:
|
|
88
|
-
process.env.LOCAL_BUNDLE_PATH ||
|
|
75
|
+
localBundlePath: process.env.LOCAL_BUNDLE_PATH ||
|
|
89
76
|
fileConfig.localBundlePath ||
|
|
90
77
|
path_1.default.join(__dirname, 'dist', 'local-control-bundle.js')
|
|
91
78
|
};
|
|
92
79
|
}
|
|
93
80
|
function runSession(remoteEnvironmentUrl, remoteScriptToIntercept, remoteStylesheetToIntercept, localBundlePath, localCssPath) {
|
|
81
|
+
if (!remoteEnvironmentUrl) {
|
|
82
|
+
color_logger_1.default.error('❌ Remote environment URL is required. Please provide it via CLI, config file, or environment variable.');
|
|
83
|
+
process.exit(1);
|
|
84
|
+
}
|
|
94
85
|
const REMOTE_ENVIRONMENT_URL = remoteEnvironmentUrl;
|
|
95
86
|
const REMOTE_SCRIPT_TO_INTERCEPT = remoteScriptToIntercept;
|
|
96
87
|
const REMOTE_STYLESHEET_TO_INTERCEPT = remoteStylesheetToIntercept;
|
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.getArg = getArg;
|
|
4
7
|
exports.getArgValue = getArgValue;
|
|
8
|
+
exports.preprocessArgs = preprocessArgs;
|
|
9
|
+
exports.resolveEnvironment = resolveEnvironment;
|
|
10
|
+
exports.applyArgumentPreprocessing = applyArgumentPreprocessing;
|
|
11
|
+
exports.addCommonOptions = addCommonOptions;
|
|
12
|
+
exports.addPathAndEnvironmentOptions = addPathAndEnvironmentOptions;
|
|
13
|
+
exports.setupLogging = setupLogging;
|
|
14
|
+
const color_logger_1 = __importDefault(require("@tywalk/color-logger"));
|
|
5
15
|
function getArg(args, arg) {
|
|
6
16
|
const index = args.indexOf(arg);
|
|
7
17
|
if (index !== -1 && index + 1 < args.length) {
|
|
@@ -18,3 +28,90 @@ function getArgValue(args, argOpts, defaultIfExists) {
|
|
|
18
28
|
const argIndex = args.indexOf(arg) + 1;
|
|
19
29
|
return (_a = args.at(argIndex)) !== null && _a !== void 0 ? _a : defaultIfExists;
|
|
20
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Preprocesses command line arguments to handle deprecated flags
|
|
33
|
+
* @param args - Raw command line arguments
|
|
34
|
+
* @returns Object containing processed args and deprecation flags
|
|
35
|
+
*/
|
|
36
|
+
function preprocessArgs(args) {
|
|
37
|
+
const processed = [...args];
|
|
38
|
+
let hadDeprecatedEnv = false;
|
|
39
|
+
// Handle deprecated -env flag (single dash) by converting to --env (double dash)
|
|
40
|
+
for (let i = 0; i < processed.length; i++) {
|
|
41
|
+
if (processed[i] === '-env') {
|
|
42
|
+
hadDeprecatedEnv = true;
|
|
43
|
+
processed[i] = '--env';
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return { args: processed, hadDeprecatedEnv };
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Resolves environment value from options with proper deprecation warnings
|
|
50
|
+
* @param options - Parsed Commander.js options
|
|
51
|
+
* @param hadDeprecatedEnv - Whether the deprecated -env flag was used
|
|
52
|
+
* @returns Resolved environment string
|
|
53
|
+
*/
|
|
54
|
+
function resolveEnvironment(options, hadDeprecatedEnv) {
|
|
55
|
+
// Check if deprecated --env flag was used
|
|
56
|
+
if (options.env && options.environment) {
|
|
57
|
+
color_logger_1.default.warn('⚠️ Both --env (deprecated) and --environment flags provided. Using --environment value.');
|
|
58
|
+
return options.environment;
|
|
59
|
+
}
|
|
60
|
+
else if (options.env) {
|
|
61
|
+
if (hadDeprecatedEnv) {
|
|
62
|
+
color_logger_1.default.warn('⚠️ The -env flag is DEPRECATED. Please use -e or --environment instead.');
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
color_logger_1.default.warn('⚠️ The --env flag is DEPRECATED. Please use -e or --environment instead.');
|
|
66
|
+
}
|
|
67
|
+
return options.env;
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
return options.environment || '';
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Applies argument preprocessing for backward compatibility
|
|
75
|
+
* @param originalArgv - The original process.argv
|
|
76
|
+
*/
|
|
77
|
+
function applyArgumentPreprocessing(originalArgv) {
|
|
78
|
+
const { args: processedArgs, hadDeprecatedEnv } = preprocessArgs(originalArgv.slice(2));
|
|
79
|
+
process.argv = [...originalArgv.slice(0, 2), ...processedArgs];
|
|
80
|
+
return { hadDeprecatedEnv };
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Adds common CLI options to a Commander.js command
|
|
84
|
+
* @param command - Commander.js command instance
|
|
85
|
+
* @returns The command with common options added
|
|
86
|
+
*/
|
|
87
|
+
function addCommonOptions(command) {
|
|
88
|
+
return command
|
|
89
|
+
.option('-V, --verbose', 'enable verbose logging')
|
|
90
|
+
.option('-t, --timeout <milliseconds>', 'timeout in milliseconds', (value) => {
|
|
91
|
+
const num = Number(value);
|
|
92
|
+
if (isNaN(num) || num <= 0) {
|
|
93
|
+
throw new Error('Timeout must be a positive number');
|
|
94
|
+
}
|
|
95
|
+
return value;
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Adds path and environment options to a Commander.js command
|
|
100
|
+
* @param command - Commander.js command instance
|
|
101
|
+
* @returns The command with path and environment options added
|
|
102
|
+
*/
|
|
103
|
+
function addPathAndEnvironmentOptions(command) {
|
|
104
|
+
return addCommonOptions(command)
|
|
105
|
+
.requiredOption('-p, --path <path>', 'path to solution folder')
|
|
106
|
+
.option('-e, --environment <environment>', 'environment name')
|
|
107
|
+
.option('--env <environment>', '[DEPRECATED: use -e/--environment] environment name (deprecated)');
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Sets up logging based on verbose option
|
|
111
|
+
* @param verbose - Whether verbose logging is enabled
|
|
112
|
+
*/
|
|
113
|
+
function setupLogging(verbose) {
|
|
114
|
+
if (verbose) {
|
|
115
|
+
color_logger_1.default.setDebug(true);
|
|
116
|
+
}
|
|
117
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tywalk/pcf-helper",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.1",
|
|
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 && npm run build && npm publish --access public"
|
|
19
19
|
},
|
|
20
20
|
"keywords": [
|
|
21
21
|
"pcf"
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
declare function loadConfig(): {
|
|
1
|
+
declare function loadConfig(config?: string): {
|
|
2
|
+
remoteEnvironmentUrl?: undefined;
|
|
3
|
+
remoteScriptToIntercept?: undefined;
|
|
4
|
+
remoteStylesheetToIntercept?: undefined;
|
|
5
|
+
localCssPath?: undefined;
|
|
6
|
+
localBundlePath?: undefined;
|
|
7
|
+
} | {
|
|
2
8
|
remoteEnvironmentUrl: any;
|
|
3
9
|
remoteScriptToIntercept: any;
|
|
4
10
|
remoteStylesheetToIntercept: any;
|
|
@@ -1,2 +1,46 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
1
2
|
export declare function getArg(args: string[], arg: string): string | undefined;
|
|
2
3
|
export declare function getArgValue(args: string[], argOpts: string[], defaultIfExists?: any): string | undefined;
|
|
4
|
+
/**
|
|
5
|
+
* Preprocesses command line arguments to handle deprecated flags
|
|
6
|
+
* @param args - Raw command line arguments
|
|
7
|
+
* @returns Object containing processed args and deprecation flags
|
|
8
|
+
*/
|
|
9
|
+
export declare function preprocessArgs(args: string[]): {
|
|
10
|
+
args: string[];
|
|
11
|
+
hadDeprecatedEnv: boolean;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Resolves environment value from options with proper deprecation warnings
|
|
15
|
+
* @param options - Parsed Commander.js options
|
|
16
|
+
* @param hadDeprecatedEnv - Whether the deprecated -env flag was used
|
|
17
|
+
* @returns Resolved environment string
|
|
18
|
+
*/
|
|
19
|
+
export declare function resolveEnvironment(options: {
|
|
20
|
+
env?: string;
|
|
21
|
+
environment?: string;
|
|
22
|
+
}, hadDeprecatedEnv: boolean): string;
|
|
23
|
+
/**
|
|
24
|
+
* Applies argument preprocessing for backward compatibility
|
|
25
|
+
* @param originalArgv - The original process.argv
|
|
26
|
+
*/
|
|
27
|
+
export declare function applyArgumentPreprocessing(originalArgv: string[]): {
|
|
28
|
+
hadDeprecatedEnv: boolean;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Adds common CLI options to a Commander.js command
|
|
32
|
+
* @param command - Commander.js command instance
|
|
33
|
+
* @returns The command with common options added
|
|
34
|
+
*/
|
|
35
|
+
export declare function addCommonOptions(command: Command): Command;
|
|
36
|
+
/**
|
|
37
|
+
* Adds path and environment options to a Commander.js command
|
|
38
|
+
* @param command - Commander.js command instance
|
|
39
|
+
* @returns The command with path and environment options added
|
|
40
|
+
*/
|
|
41
|
+
export declare function addPathAndEnvironmentOptions(command: Command): Command;
|
|
42
|
+
/**
|
|
43
|
+
* Sets up logging based on verbose option
|
|
44
|
+
* @param verbose - Whether verbose logging is enabled
|
|
45
|
+
*/
|
|
46
|
+
export declare function setupLogging(verbose?: boolean): void;
|