piral-cli 0.14.8-beta.3480 → 0.14.8-beta.3494

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.
@@ -17,7 +17,7 @@ const io_1 = require("./io");
17
17
  const log_1 = require("./log");
18
18
  function getTemplatePackage(templatePackageName) {
19
19
  const idx = templatePackageName.indexOf('@', 1);
20
- const normalizedName = idx > 0 ? templatePackageName.substr(0, idx) : templatePackageName;
20
+ const normalizedName = idx > 0 && !(0, path_1.isAbsolute)(templatePackageName) ? templatePackageName.substr(0, idx) : templatePackageName;
21
21
  try {
22
22
  return require(normalizedName);
23
23
  }
@@ -27,7 +27,13 @@ function getTemplatePackage(templatePackageName) {
27
27
  }
28
28
  function getTemplateFiles(templatePackageName, registry, root, data) {
29
29
  return __awaiter(this, void 0, void 0, function* () {
30
- yield (0, npm_1.installPackage)(templatePackageName, __dirname, '--registry', registry);
30
+ // debug in monorepo such as "../templates/pilet-template-react/lib/index.js"
31
+ if (templatePackageName.startsWith('.')) {
32
+ templatePackageName = (0, path_1.resolve)(process.cwd(), templatePackageName);
33
+ }
34
+ else {
35
+ yield (0, npm_1.installPackage)(templatePackageName, __dirname, '--registry', registry);
36
+ }
31
37
  const templateRunner = getTemplatePackage(templatePackageName);
32
38
  if (typeof templateRunner === 'function') {
33
39
  return yield templateRunner(root, data);
@@ -1 +1 @@
1
- {"version":3,"file":"scaffold.js","sourceRoot":"","sources":["../../src/common/scaffold.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+BAAwD;AACxD,uCAA+C;AAC/C,mCAAyD;AACzD,6BAAkF;AAClF,+BAAkC;AAQlC,SAAS,kBAAkB,CAAC,mBAA2B;IACrD,MAAM,GAAG,GAAG,mBAAmB,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IAChD,MAAM,cAAc,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC,EAAE,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AAE,QAAQ,CAAC,CAAC;QAEtE,MAAM,IAAA,oBAAe,EAAC,GAAG,CAAC,CAAC;QAE3B,MAAM,KAAK,GAAG,MAAM,gBAAgB,CAAC,mBAAmB,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QAEhF,MAAM,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC;IAChD,CAAC;CAAA;AAdD,4DAcC;AAED,SAAgB,oBAAoB,CAClC,QAAwB,EACxB,IAAY,EACZ,UAAkB,EAClB,SAAiC;IAEjC,MAAM,GAAG,GAAG,IAAA,WAAI,EAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC9B,uCACK,SAAS,KACZ,IAAI;QACJ,GAAG,EACH,QAAQ,EAAE,eAAe,CAAC,QAAQ,CAAC,EACnC,UAAU,IACV;AACJ,CAAC;AAdD,oDAcC;AAED,SAAsB,wBAAwB,CAC5C,QAAgB,EAChB,QAAgB,EAChB,IAA6C,EAC7C,cAA8B;;QAE9B,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;QAC3B,MAAM,mBAAmB,GAAG,sBAAsB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QAEtE,MAAM,IAAA,oBAAe,EAAC,GAAG,CAAC,CAAC;QAE3B,MAAM,KAAK,GAAG,MAAM,gBAAgB,CAAC,mBAAmB,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QAEhF,MAAM,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC;IAChD,CAAC;CAAA;AAdD,4DAcC"}
@@ -31271,7 +31271,6 @@ module.exports = input => typeof input === 'string' ? input.replace(ansiRegex(),
31271
31271
 
31272
31272
  module.exports = glob
31273
31273
 
31274
- var fs = __webpack_require__(747)
31275
31274
  var rp = __webpack_require__(741)
31276
31275
  var minimatch = __webpack_require__(170)
31277
31276
  var Minimatch = minimatch.Minimatch
@@ -31732,7 +31731,7 @@ Glob.prototype._readdirInGlobStar = function (abs, cb) {
31732
31731
  var lstatcb = inflight(lstatkey, lstatcb_)
31733
31732
 
31734
31733
  if (lstatcb)
31735
- fs.lstat(abs, lstatcb)
31734
+ self.fs.lstat(abs, lstatcb)
31736
31735
 
31737
31736
  function lstatcb_ (er, lstat) {
31738
31737
  if (er && er.code === 'ENOENT')
@@ -31773,7 +31772,7 @@ Glob.prototype._readdir = function (abs, inGlobStar, cb) {
31773
31772
  }
31774
31773
 
31775
31774
  var self = this
31776
- fs.readdir(abs, readdirCb(this, abs, cb))
31775
+ self.fs.readdir(abs, readdirCb(this, abs, cb))
31777
31776
  }
31778
31777
 
31779
31778
  function readdirCb (self, abs, cb) {
@@ -31977,13 +31976,13 @@ Glob.prototype._stat = function (f, cb) {
31977
31976
  var self = this
31978
31977
  var statcb = inflight('stat\0' + abs, lstatcb_)
31979
31978
  if (statcb)
31980
- fs.lstat(abs, statcb)
31979
+ self.fs.lstat(abs, statcb)
31981
31980
 
31982
31981
  function lstatcb_ (er, lstat) {
31983
31982
  if (lstat && lstat.isSymbolicLink()) {
31984
31983
  // If it's a symlink, then treat it as the target, unless
31985
31984
  // the target does not exist, then treat it as a file.
31986
- return fs.stat(abs, function (er, stat) {
31985
+ return self.fs.stat(abs, function (er, stat) {
31987
31986
  if (er)
31988
31987
  self._stat2(f, abs, null, lstat, cb)
31989
31988
  else
@@ -46043,7 +46042,7 @@ events.forEach(function (event) {
46043
46042
  // Error types with codes
46044
46043
  var RedirectionError = createErrorType(
46045
46044
  "ERR_FR_REDIRECTION_FAILURE",
46046
- ""
46045
+ "Redirected request failed"
46047
46046
  );
46048
46047
  var TooManyRedirectsError = createErrorType(
46049
46048
  "ERR_FR_TOO_MANY_REDIRECTS",
@@ -46172,10 +46171,8 @@ RedirectableRequest.prototype.removeHeader = function (name) {
46172
46171
  // Global timeout for all underlying requests
46173
46172
  RedirectableRequest.prototype.setTimeout = function (msecs, callback) {
46174
46173
  var self = this;
46175
- if (callback) {
46176
- this.on("timeout", callback);
46177
- }
46178
46174
 
46175
+ // Destroys the socket on timeout
46179
46176
  function destroyOnTimeout(socket) {
46180
46177
  socket.setTimeout(msecs);
46181
46178
  socket.removeListener("timeout", socket.destroy);
@@ -46194,18 +46191,32 @@ RedirectableRequest.prototype.setTimeout = function (msecs, callback) {
46194
46191
  destroyOnTimeout(socket);
46195
46192
  }
46196
46193
 
46197
- // Prevent a timeout from triggering
46194
+ // Stops a timeout from triggering
46198
46195
  function clearTimer() {
46199
- clearTimeout(self._timeout);
46196
+ // Clear the timeout
46197
+ if (self._timeout) {
46198
+ clearTimeout(self._timeout);
46199
+ self._timeout = null;
46200
+ }
46201
+
46202
+ // Clean up all attached listeners
46203
+ self.removeListener("abort", clearTimer);
46204
+ self.removeListener("error", clearTimer);
46205
+ self.removeListener("response", clearTimer);
46200
46206
  if (callback) {
46201
46207
  self.removeListener("timeout", callback);
46202
46208
  }
46203
- if (!this.socket) {
46209
+ if (!self.socket) {
46204
46210
  self._currentRequest.removeListener("socket", startTimer);
46205
46211
  }
46206
46212
  }
46207
46213
 
46208
- // Start the timer when the socket is opened
46214
+ // Attach callback if passed
46215
+ if (callback) {
46216
+ this.on("timeout", callback);
46217
+ }
46218
+
46219
+ // Start the timer if or when the socket is opened
46209
46220
  if (this.socket) {
46210
46221
  startTimer(this.socket);
46211
46222
  }
@@ -46213,9 +46224,11 @@ RedirectableRequest.prototype.setTimeout = function (msecs, callback) {
46213
46224
  this._currentRequest.once("socket", startTimer);
46214
46225
  }
46215
46226
 
46227
+ // Clean up on events
46216
46228
  this.on("socket", destroyOnTimeout);
46217
- this.once("response", clearTimer);
46218
- this.once("error", clearTimer);
46229
+ this.on("abort", clearTimer);
46230
+ this.on("error", clearTimer);
46231
+ this.on("response", clearTimer);
46219
46232
 
46220
46233
  return this;
46221
46234
  };
@@ -46379,19 +46392,33 @@ RedirectableRequest.prototype._processResponse = function (response) {
46379
46392
  }
46380
46393
 
46381
46394
  // Drop the Host header, as the redirect might lead to a different host
46382
- var previousHostName = removeMatchingHeaders(/^host$/i, this._options.headers) ||
46383
- url.parse(this._currentUrl).hostname;
46395
+ var currentHostHeader = removeMatchingHeaders(/^host$/i, this._options.headers);
46396
+
46397
+ // If the redirect is relative, carry over the host of the last request
46398
+ var currentUrlParts = url.parse(this._currentUrl);
46399
+ var currentHost = currentHostHeader || currentUrlParts.host;
46400
+ var currentUrl = /^\w+:/.test(location) ? this._currentUrl :
46401
+ url.format(Object.assign(currentUrlParts, { host: currentHost }));
46402
+
46403
+ // Determine the URL of the redirection
46404
+ var redirectUrl;
46405
+ try {
46406
+ redirectUrl = url.resolve(currentUrl, location);
46407
+ }
46408
+ catch (cause) {
46409
+ this.emit("error", new RedirectionError(cause));
46410
+ return;
46411
+ }
46384
46412
 
46385
46413
  // Create the redirected request
46386
- var redirectUrl = url.resolve(this._currentUrl, location);
46387
46414
  debug("redirecting to", redirectUrl);
46388
46415
  this._isRedirect = true;
46389
46416
  var redirectUrlParts = url.parse(redirectUrl);
46390
46417
  Object.assign(this._options, redirectUrlParts);
46391
46418
 
46392
- // Drop the Authorization header if redirecting to another host
46393
- if (redirectUrlParts.hostname !== previousHostName) {
46394
- removeMatchingHeaders(/^authorization$/i, this._options.headers);
46419
+ // Drop the confidential headers when redirecting to another domain
46420
+ if (!(redirectUrlParts.host === currentHost || isSubdomainOf(redirectUrlParts.host, currentHost))) {
46421
+ removeMatchingHeaders(/^(?:authorization|cookie)$/i, this._options.headers);
46395
46422
  }
46396
46423
 
46397
46424
  // Evaluate the beforeRedirect callback
@@ -46412,9 +46439,7 @@ RedirectableRequest.prototype._processResponse = function (response) {
46412
46439
  this._performRequest();
46413
46440
  }
46414
46441
  catch (cause) {
46415
- var error = new RedirectionError("Redirected request failed: " + cause.message);
46416
- error.cause = cause;
46417
- this.emit("error", error);
46442
+ this.emit("error", new RedirectionError(cause));
46418
46443
  }
46419
46444
  }
46420
46445
  else {
@@ -46528,13 +46553,20 @@ function removeMatchingHeaders(regex, headers) {
46528
46553
  delete headers[header];
46529
46554
  }
46530
46555
  }
46531
- return lastValue;
46556
+ return (lastValue === null || typeof lastValue === "undefined") ?
46557
+ undefined : String(lastValue).trim();
46532
46558
  }
46533
46559
 
46534
46560
  function createErrorType(code, defaultMessage) {
46535
- function CustomError(message) {
46561
+ function CustomError(cause) {
46536
46562
  Error.captureStackTrace(this, this.constructor);
46537
- this.message = message || defaultMessage;
46563
+ if (!cause) {
46564
+ this.message = defaultMessage;
46565
+ }
46566
+ else {
46567
+ this.message = defaultMessage + ": " + cause.message;
46568
+ this.cause = cause;
46569
+ }
46538
46570
  }
46539
46571
  CustomError.prototype = new Error();
46540
46572
  CustomError.prototype.constructor = CustomError;
@@ -46551,6 +46583,11 @@ function abortRequest(request) {
46551
46583
  request.abort();
46552
46584
  }
46553
46585
 
46586
+ function isSubdomainOf(subdomain, domain) {
46587
+ const dot = subdomain.length - domain.length - 1;
46588
+ return dot > 0 && subdomain[dot] === "." && subdomain.endsWith(domain);
46589
+ }
46590
+
46554
46591
  // Exports
46555
46592
  module.exports = wrap({ http: http, https: https });
46556
46593
  module.exports.wrap = wrap;
@@ -49168,7 +49205,6 @@ module.exports = (chalk, tmp) => {
49168
49205
  module.exports = globSync
49169
49206
  globSync.GlobSync = GlobSync
49170
49207
 
49171
- var fs = __webpack_require__(747)
49172
49208
  var rp = __webpack_require__(741)
49173
49209
  var minimatch = __webpack_require__(170)
49174
49210
  var Minimatch = minimatch.Minimatch
@@ -49413,7 +49449,7 @@ GlobSync.prototype._readdirInGlobStar = function (abs) {
49413
49449
  var lstat
49414
49450
  var stat
49415
49451
  try {
49416
- lstat = fs.lstatSync(abs)
49452
+ lstat = this.fs.lstatSync(abs)
49417
49453
  } catch (er) {
49418
49454
  if (er.code === 'ENOENT') {
49419
49455
  // lstat failed, doesn't exist
@@ -49450,7 +49486,7 @@ GlobSync.prototype._readdir = function (abs, inGlobStar) {
49450
49486
  }
49451
49487
 
49452
49488
  try {
49453
- return this._readdirEntries(abs, fs.readdirSync(abs))
49489
+ return this._readdirEntries(abs, this.fs.readdirSync(abs))
49454
49490
  } catch (er) {
49455
49491
  this._readdirError(abs, er)
49456
49492
  return null
@@ -49609,7 +49645,7 @@ GlobSync.prototype._stat = function (f) {
49609
49645
  if (!stat) {
49610
49646
  var lstat
49611
49647
  try {
49612
- lstat = fs.lstatSync(abs)
49648
+ lstat = this.fs.lstatSync(abs)
49613
49649
  } catch (er) {
49614
49650
  if (er && (er.code === 'ENOENT' || er.code === 'ENOTDIR')) {
49615
49651
  this.statCache[abs] = false
@@ -49619,7 +49655,7 @@ GlobSync.prototype._stat = function (f) {
49619
49655
 
49620
49656
  if (lstat && lstat.isSymbolicLink()) {
49621
49657
  try {
49622
- stat = fs.statSync(abs)
49658
+ stat = this.fs.statSync(abs)
49623
49659
  } catch (er) {
49624
49660
  stat = lstat
49625
49661
  }
@@ -50287,6 +50323,7 @@ function ownProp (obj, field) {
50287
50323
  return Object.prototype.hasOwnProperty.call(obj, field)
50288
50324
  }
50289
50325
 
50326
+ var fs = __webpack_require__(747)
50290
50327
  var path = __webpack_require__(622)
50291
50328
  var minimatch = __webpack_require__(170)
50292
50329
  var isAbsolute = __webpack_require__(418)
@@ -50352,6 +50389,7 @@ function setopts (self, pattern, options) {
50352
50389
  self.stat = !!options.stat
50353
50390
  self.noprocess = !!options.noprocess
50354
50391
  self.absolute = !!options.absolute
50392
+ self.fs = options.fs || fs
50355
50393
 
50356
50394
  self.maxLength = options.maxLength || Infinity
50357
50395
  self.cache = options.cache || Object.create(null)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "piral-cli",
3
- "version": "0.14.8-beta.3480",
3
+ "version": "0.14.8-beta.3494",
4
4
  "description": "The standard CLI for creating and building a Piral instance or a Pilet.",
5
5
  "keywords": [
6
6
  "portal",
@@ -77,5 +77,5 @@
77
77
  "typescript": "^4.0.2",
78
78
  "yargs": "^15.4.1"
79
79
  },
80
- "gitHead": "a35bd0eb547a18a708af0df85f66a21aa76bdb76"
80
+ "gitHead": "e0cf86abbcc310101a68de1297c4c9104815cb77"
81
81
  }
@@ -1,4 +1,4 @@
1
- import { join, dirname, resolve, basename } from 'path';
1
+ import { join, dirname, resolve, basename, isAbsolute } from 'path';
2
2
  import { installPackage } from './clients/npm';
3
3
  import { ForceOverwrite, SourceLanguage } from './enums';
4
4
  import { createDirectory, createFileIfNotExists, updateExistingJson } from './io';
@@ -12,7 +12,8 @@ interface TemplateFile {
12
12
 
13
13
  function getTemplatePackage(templatePackageName: string) {
14
14
  const idx = templatePackageName.indexOf('@', 1);
15
- const normalizedName = idx > 0 ? templatePackageName.substr(0, idx) : templatePackageName;
15
+ const normalizedName =
16
+ idx > 0 && !isAbsolute(templatePackageName) ? templatePackageName.substr(0, idx) : templatePackageName;
16
17
 
17
18
  try {
18
19
  return require(normalizedName);
@@ -30,7 +31,12 @@ async function getTemplateFiles(
30
31
  root: string,
31
32
  data: Record<string, any>,
32
33
  ): Promise<Array<TemplateFile>> {
33
- await installPackage(templatePackageName, __dirname, '--registry', registry);
34
+ // debug in monorepo such as "../templates/pilet-template-react/lib/index.js"
35
+ if (templatePackageName.startsWith('.')) {
36
+ templatePackageName = resolve(process.cwd(), templatePackageName);
37
+ } else {
38
+ await installPackage(templatePackageName, __dirname, '--registry', registry);
39
+ }
34
40
  const templateRunner = getTemplatePackage(templatePackageName);
35
41
 
36
42
  if (typeof templateRunner === 'function') {