@tywalk/pcf-helper-run 1.2.13 → 1.2.15
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/index.js +23 -15
- package/dist/package.json +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -33,6 +33,15 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
return result;
|
|
34
34
|
};
|
|
35
35
|
})();
|
|
36
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
37
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
38
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
39
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
40
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
41
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
42
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
43
|
+
});
|
|
44
|
+
};
|
|
36
45
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
46
|
const commander_1 = require("commander");
|
|
38
47
|
const tasks = __importStar(require("@tywalk/pcf-helper"));
|
|
@@ -113,7 +122,7 @@ const setupExecutionContext = (options) => {
|
|
|
113
122
|
return { logger, tick: performance.now() };
|
|
114
123
|
};
|
|
115
124
|
// Helper function to execute tasks and handle results
|
|
116
|
-
const
|
|
125
|
+
const handleResults = (taskName, logger, tick, result) => {
|
|
117
126
|
if (taskName !== 'session') {
|
|
118
127
|
if (result === 0) {
|
|
119
128
|
logger.log(`[PCF Helper Run] ${taskName} completed successfully!`);
|
|
@@ -146,7 +155,7 @@ addPathOptions(commander_1.program.command('upgrade'))
|
|
|
146
155
|
logger.error('[PCF Helper Run] One or more tasks failed while upgrading: ', (e && e.message) || 'unknown error');
|
|
147
156
|
result = 1;
|
|
148
157
|
}
|
|
149
|
-
|
|
158
|
+
handleResults('upgrade', logger, tick, result);
|
|
150
159
|
});
|
|
151
160
|
// Define the build command
|
|
152
161
|
addPathOptions(commander_1.program.command('build'))
|
|
@@ -166,7 +175,7 @@ addPathOptions(commander_1.program.command('build'))
|
|
|
166
175
|
logger.error('[PCF Helper Run] One or more tasks failed while building: ', (e && e.message) || 'unknown error');
|
|
167
176
|
result = 1;
|
|
168
177
|
}
|
|
169
|
-
|
|
178
|
+
handleResults('build', logger, tick, result);
|
|
170
179
|
});
|
|
171
180
|
// Define the import command
|
|
172
181
|
addPathOptions(commander_1.program.command('import'))
|
|
@@ -190,7 +199,7 @@ addPathOptions(commander_1.program.command('import'))
|
|
|
190
199
|
logger.error('[PCF Helper Run] One or more tasks failed while importing: ', (e && e.message) || 'unknown error');
|
|
191
200
|
result = 1;
|
|
192
201
|
}
|
|
193
|
-
|
|
202
|
+
handleResults('import', logger, tick, result);
|
|
194
203
|
});
|
|
195
204
|
// Define the deploy command (runs upgrade, build, and import)
|
|
196
205
|
addPathOptions(commander_1.program.command('deploy'))
|
|
@@ -232,7 +241,7 @@ addPathOptions(commander_1.program.command('deploy'))
|
|
|
232
241
|
logger.error('[PCF Helper Run] One or more tasks failed while deploying: ', (e && e.message) || 'unknown error');
|
|
233
242
|
result = 1;
|
|
234
243
|
}
|
|
235
|
-
|
|
244
|
+
handleResults('deploy', logger, tick, result);
|
|
236
245
|
});
|
|
237
246
|
// Define the init command
|
|
238
247
|
addCommonOptions(commander_1.program.command('init'))
|
|
@@ -253,7 +262,7 @@ addCommonOptions(commander_1.program.command('init'))
|
|
|
253
262
|
logger.error('[PCF Helper Run] One or more tasks failed while initializing: ', (e && e.message) || 'unknown error');
|
|
254
263
|
result = 1;
|
|
255
264
|
}
|
|
256
|
-
|
|
265
|
+
handleResults('init', logger, tick, result);
|
|
257
266
|
});
|
|
258
267
|
// Define the session command
|
|
259
268
|
addCommonOptions(commander_1.program.command('session'))
|
|
@@ -265,25 +274,24 @@ addCommonOptions(commander_1.program.command('session'))
|
|
|
265
274
|
.option('-c, --local-css <path>', 'local CSS path')
|
|
266
275
|
.option('-f, --config <path>', 'config file path', 'session.config.json')
|
|
267
276
|
.option('-w, --watch', 'start pcf-scripts watch process')
|
|
268
|
-
.action((options) => {
|
|
269
|
-
var _a, _b, _c, _d, _e
|
|
277
|
+
.action((options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
278
|
+
var _a, _b, _c, _d, _e;
|
|
270
279
|
const { logger, tick } = setupExecutionContext(options);
|
|
271
|
-
let result = 0;
|
|
272
280
|
try {
|
|
273
281
|
logger.log('[PCF Helper Run] ' + (0, performanceUtil_1.formatTime)(new Date()) + ' session started.\n');
|
|
274
282
|
if (!options.url || options.config) {
|
|
275
283
|
const config = tasks.loadConfig(options.config || 'session.config.json');
|
|
276
|
-
tasks.runSession((_a = config.remoteEnvironmentUrl) !== null && _a !== void 0 ? _a : options.url, (_b = config.remoteScriptToIntercept) !== null && _b !== void 0 ? _b : options.script, (_c = config.remoteStylesheetToIntercept) !== null && _c !== void 0 ? _c : options.stylesheet, (_d = config.localBundlePath) !== null && _d !== void 0 ? _d : options.bundle, (_e = config.localCssPath) !== null && _e !== void 0 ? _e : options.css,
|
|
284
|
+
yield tasks.runSession((_a = config.remoteEnvironmentUrl) !== null && _a !== void 0 ? _a : options.url, (_b = config.remoteScriptToIntercept) !== null && _b !== void 0 ? _b : options.script, (_c = config.remoteStylesheetToIntercept) !== null && _c !== void 0 ? _c : options.stylesheet, (_d = config.localBundlePath) !== null && _d !== void 0 ? _d : options.bundle, (_e = config.localCssPath) !== null && _e !== void 0 ? _e : options.css, config.startWatch || options.watch);
|
|
277
285
|
}
|
|
278
286
|
else {
|
|
279
|
-
tasks.runSession(options.url, options.script, options.stylesheet, options.bundle, options.css, options.watch);
|
|
287
|
+
yield tasks.runSession(options.url, options.script, options.stylesheet, options.bundle, options.css, options.watch);
|
|
280
288
|
}
|
|
289
|
+
const tock = performance.now();
|
|
290
|
+
logger.log((0, performanceUtil_1.formatMsToSec)('Session started successfully in %is.', tock - tick));
|
|
281
291
|
}
|
|
282
292
|
catch (e) {
|
|
283
|
-
logger.error('[PCF Helper Run] One or more tasks failed during session: ', (e && e.message) || 'unknown error');
|
|
284
|
-
result = 1;
|
|
293
|
+
logger.error('[PCF Helper Run] One or more tasks failed during session or session startup: ', (e && e.message) || 'unknown error');
|
|
285
294
|
}
|
|
286
|
-
|
|
287
|
-
});
|
|
295
|
+
}));
|
|
288
296
|
// Parse the command line arguments
|
|
289
297
|
commander_1.program.parse();
|
package/dist/package.json
CHANGED