piral-cli 0.15.0-alpha.4231 → 0.15.0-alpha.4311

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.
Files changed (94) hide show
  1. package/README.md +7 -5
  2. package/lib/apps/debug-pilet.js +28 -42
  3. package/lib/apps/debug-pilet.js.map +1 -1
  4. package/lib/apps/debug-piral.js +20 -34
  5. package/lib/apps/debug-piral.js.map +1 -1
  6. package/lib/apps/new-pilet.js +3 -3
  7. package/lib/apps/new-pilet.js.map +1 -1
  8. package/lib/apps/new-piral.js +7 -3
  9. package/lib/apps/new-piral.js.map +1 -1
  10. package/lib/apps/publish-piral.d.ts +2 -2
  11. package/lib/apps/publish-piral.js +9 -8
  12. package/lib/apps/publish-piral.js.map +1 -1
  13. package/lib/apps/upgrade-pilet.js +2 -2
  14. package/lib/apps/upgrade-pilet.js.map +1 -1
  15. package/lib/apps/upgrade-piral.js +2 -2
  16. package/lib/apps/upgrade-piral.js.map +1 -1
  17. package/lib/commands.js +10 -10
  18. package/lib/commands.js.map +1 -1
  19. package/lib/common/clients/index.d.ts +3 -1
  20. package/lib/common/clients/index.js +3 -1
  21. package/lib/common/clients/index.js.map +1 -1
  22. package/lib/common/clients/npm.d.ts +1 -0
  23. package/lib/common/clients/npm.js +7 -1
  24. package/lib/common/clients/npm.js.map +1 -1
  25. package/lib/common/clients/pnp.d.ts +6 -0
  26. package/lib/common/clients/pnp.js +95 -0
  27. package/lib/common/clients/pnp.js.map +1 -0
  28. package/lib/common/clients/yarn.js +3 -3
  29. package/lib/common/clients/yarn.js.map +1 -1
  30. package/lib/common/http.d.ts +4 -2
  31. package/lib/common/http.js +25 -11
  32. package/lib/common/http.js.map +1 -1
  33. package/lib/common/injectors.d.ts +36 -7
  34. package/lib/common/injectors.js +39 -11
  35. package/lib/common/injectors.js.map +1 -1
  36. package/lib/common/interactive.js +10 -5
  37. package/lib/common/interactive.js.map +1 -1
  38. package/lib/common/log.d.ts +1 -0
  39. package/lib/common/log.js +9 -2
  40. package/lib/common/log.js.map +1 -1
  41. package/lib/common/npm.d.ts +1 -1
  42. package/lib/common/npm.js +13 -5
  43. package/lib/common/npm.js.map +1 -1
  44. package/lib/common/port.d.ts +1 -0
  45. package/lib/common/port.js +11 -1
  46. package/lib/common/port.js.map +1 -1
  47. package/lib/helpers.d.ts +3 -3
  48. package/lib/helpers.js +10 -10
  49. package/lib/helpers.js.map +1 -1
  50. package/lib/injectors/{pilet.d.ts → pilet-injector.d.ts} +1 -0
  51. package/lib/injectors/{pilet.js → pilet-injector.js} +27 -29
  52. package/lib/injectors/pilet-injector.js.map +1 -0
  53. package/lib/injectors/{piral.d.ts → piral-injector.d.ts} +1 -0
  54. package/lib/injectors/{piral.js → piral-injector.js} +20 -22
  55. package/lib/injectors/piral-injector.js.map +1 -0
  56. package/lib/messages.d.ts +83 -5
  57. package/lib/messages.js +95 -8
  58. package/lib/messages.js.map +1 -1
  59. package/lib/release.d.ts +1 -1
  60. package/lib/release.js +32 -5
  61. package/lib/release.js.map +1 -1
  62. package/lib/types/common.d.ts +1 -1
  63. package/lib/types/public.d.ts +1 -1
  64. package/package.json +3 -3
  65. package/src/apps/debug-pilet.ts +28 -48
  66. package/src/apps/debug-piral.ts +22 -37
  67. package/src/apps/new-pilet.ts +3 -2
  68. package/src/apps/new-piral.ts +9 -2
  69. package/src/apps/publish-piral.ts +21 -10
  70. package/src/apps/upgrade-pilet.ts +2 -1
  71. package/src/apps/upgrade-piral.ts +2 -1
  72. package/src/commands.ts +13 -13
  73. package/src/common/clients/index.ts +3 -1
  74. package/src/common/clients/npm.ts +4 -0
  75. package/src/common/clients/pnp.ts +77 -0
  76. package/src/common/clients/yarn.ts +3 -3
  77. package/src/common/http.ts +37 -14
  78. package/src/common/injectors.ts +46 -17
  79. package/src/common/interactive.ts +12 -7
  80. package/src/common/log.ts +9 -1
  81. package/src/common/npm.ts +21 -6
  82. package/src/common/port.ts +10 -0
  83. package/src/helpers.test.ts +5 -5
  84. package/src/helpers.ts +7 -7
  85. package/src/injectors/{pilet.test.ts → pilet-injector.test.ts} +10 -1
  86. package/src/injectors/{pilet.ts → pilet-injector.ts} +33 -25
  87. package/src/injectors/{piral.test.ts → piral-injector.test.ts} +5 -1
  88. package/src/injectors/{piral.ts → piral-injector.ts} +24 -17
  89. package/src/messages.ts +93 -6
  90. package/src/release.ts +40 -6
  91. package/src/types/common.ts +1 -1
  92. package/src/types/public.ts +1 -1
  93. package/lib/injectors/pilet.js.map +0 -1
  94. package/lib/injectors/piral.js.map +0 -1
@@ -1,6 +1,7 @@
1
1
  import { Agent } from 'https';
2
2
  import { openBrowserAt } from './browser';
3
3
  import { standardHeaders } from './info';
4
+ import { logSuspend } from './log';
4
5
  import { axios, inquirer } from '../external';
5
6
  import { PiletPublishScheme } from '../types';
6
7
 
@@ -35,6 +36,8 @@ const tokenRetrievers: Record<string, TokenResult> = {};
35
36
 
36
37
  export function getTokenInteractively(url: string, httpsAgent: Agent): TokenResult {
37
38
  if (!(url in tokenRetrievers)) {
39
+ const logResume = logSuspend();
40
+
38
41
  tokenRetrievers[url] = axios.default
39
42
  .post(
40
43
  url,
@@ -53,19 +56,21 @@ export function getTokenInteractively(url: string, httpsAgent: Agent): TokenResu
53
56
  )
54
57
  .then((res) => {
55
58
  const { loginUrl, callbackUrl, expires } = res.data;
56
- console.log(`Use the URL below to complete the login. The link expires at ${new Date(expires)}.`);
59
+ const now = new Date();
60
+ const then = new Date(expires);
61
+ const diff = ~~((then.valueOf() - now.valueOf()) / (60 * 1000));
62
+
63
+ console.log(`Use the URL below to complete the login. The link expires in ${diff} minutes (${then}).`);
57
64
  console.log('===');
58
65
  console.log(loginUrl);
59
66
  console.log('===');
60
67
 
61
68
  openBrowserAt(loginUrl);
62
69
 
63
- return axios.default.get(callbackUrl).then(({ data }) => {
64
- console.log('Logged in successfully.');
65
- return {
66
- ...data,
67
- };
68
- });
70
+ return axios.default
71
+ .get(callbackUrl)
72
+ .then(({ data }) => ({ ...data }))
73
+ .finally(logResume);
69
74
  });
70
75
  }
71
76
 
package/src/common/log.ts CHANGED
@@ -8,6 +8,7 @@ import { LogLevels, QuickMessage } from '../types';
8
8
 
9
9
  type Messages = typeof messages;
10
10
  type MessageTypes = keyof Messages;
11
+ let currentProgress: string = undefined;
11
12
 
12
13
  const logger = (() => {
13
14
  try {
@@ -92,7 +93,8 @@ export function logFail(message: string, ...args: Array<string | number | boolea
92
93
  }
93
94
 
94
95
  export function progress(message: string, ...args: Array<string | number | boolean>) {
95
- logger.progress(format(message, ...args));
96
+ currentProgress = format(message, ...args)
97
+ logger.progress(currentProgress);
96
98
  }
97
99
 
98
100
  export function logReset() {
@@ -100,6 +102,12 @@ export function logReset() {
100
102
  logger.stopSpinner();
101
103
  }
102
104
 
105
+ export function logSuspend() {
106
+ logReset();
107
+
108
+ return () => logger.progress(currentProgress);
109
+ }
110
+
103
111
  export function fail<T extends MessageTypes>(type: T, ...args: Parameters<Messages[T]>): never {
104
112
  const message = log(type, ...args);
105
113
  const error = new Error(message);
package/src/common/npm.ts CHANGED
@@ -43,6 +43,10 @@ async function detectMonorepoRoot(root: string): Promise<[] | [string, NpmClient
43
43
  const packageJson = await readJson(root, 'package.json');
44
44
 
45
45
  if (Array.isArray(packageJson?.workspaces)) {
46
+ if (await checkExists(resolve(root, '.pnp.cjs'))) {
47
+ return [root, 'pnp'];
48
+ }
49
+
46
50
  if (await checkExists(resolve(root, 'yarn.lock'))) {
47
51
  return [root, 'yarn'];
48
52
  }
@@ -74,8 +78,6 @@ export async function determineNpmClient(root: string, selected?: NpmClientType)
74
78
  `Results of the lock file check: ${searchedClients.map((m) => `${m.client}=${m.result}`).join(', ')}`,
75
79
  );
76
80
 
77
- const defaultClient = config.npmClient;
78
-
79
81
  if (foundClients.length > 1) {
80
82
  const wrapperClient = foundClients.find((m) => isWrapperClient(m.client));
81
83
 
@@ -97,12 +99,14 @@ export async function determineNpmClient(root: string, selected?: NpmClientType)
97
99
  return client;
98
100
  }
99
101
 
102
+ const defaultClient = config.npmClient;
103
+
100
104
  if (clientTypeKeys.includes(defaultClient)) {
101
105
  log('generalDebug_0003', `Using the default client: "${defaultClient}".`);
102
106
  return defaultClient;
103
107
  }
104
108
 
105
- log('generalDebug_0003', 'Using the default "npm" client.');
109
+ log('generalDebug_0003', 'Using the fallback "npm" client.');
106
110
  return 'npm';
107
111
  }
108
112
 
@@ -148,9 +152,20 @@ export function initNpmProject(client: NpmClientType, projectName: string, targe
148
152
  return initProject(projectName, target);
149
153
  }
150
154
 
151
- export function publishNpmPackage(target = '.', file = '*.tgz', flags: Array<string> = []): Promise<string> {
152
- const { publishPackage } = clients.npm;
153
- return publishPackage(target, file, ...flags);
155
+ export function publishNpmPackage(
156
+ target = '.',
157
+ file = '*.tgz',
158
+ flags: Array<string> = [],
159
+ interactive = false,
160
+ ): Promise<string> {
161
+ const { publishPackage, loginUser } = clients.npm;
162
+ return publishPackage(target, file, ...flags).catch(err => {
163
+ if (!interactive) {
164
+ throw err;
165
+ }
166
+
167
+ return loginUser().then(() => publishNpmPackage(target, file, flags, false));
168
+ });
154
169
  }
155
170
 
156
171
  export function createNpmPackage(target = '.'): Promise<string> {
@@ -1,6 +1,16 @@
1
1
  import { log } from './log';
2
2
  import { getPort } from '../external';
3
3
 
4
+ export async function getAvailablePort(defaultPort: number) {
5
+ const selectedPort = await getFreePort(defaultPort);
6
+
7
+ if (selectedPort !== defaultPort) {
8
+ log('portNotFree_0047', selectedPort, defaultPort);
9
+ }
10
+
11
+ return selectedPort;
12
+ }
13
+
4
14
  export async function getFreePort(preferred?: number) {
5
15
  log('generalDebug_0003', `Looking for a free port. Preferred port: ${preferred}`);
6
16
  const port = await getPort(preferred && { port: preferred });
@@ -1,4 +1,4 @@
1
- import { keyOfForceOverwrite, keyOfPiletLanguage, valueOfForceOverwrite, valueOfPiletLanguage } from './helpers';
1
+ import { keyOfForceOverwrite, keyOfSourceLanguage, valueOfForceOverwrite, valueOfSourceLanguage } from './helpers';
2
2
  import { ForceOverwrite, SourceLanguage } from './common/enums';
3
3
 
4
4
  describe('Piral CLI Command Helpers Module', () => {
@@ -13,12 +13,12 @@ describe('Piral CLI Command Helpers Module', () => {
13
13
  });
14
14
 
15
15
  it('correct value of keyOfPiletLanguage results in same key', () => {
16
- const result = keyOfPiletLanguage(SourceLanguage.ts);
16
+ const result = keyOfSourceLanguage(SourceLanguage.ts);
17
17
  expect(result).toBe('ts');
18
18
  });
19
19
 
20
20
  it('incorrect value of keyOfPiletLanguage results in key for TS', () => {
21
- const result = keyOfPiletLanguage(5);
21
+ const result = keyOfSourceLanguage(5);
22
22
  expect(result).toBe('ts');
23
23
  });
24
24
 
@@ -33,12 +33,12 @@ describe('Piral CLI Command Helpers Module', () => {
33
33
  });
34
34
 
35
35
  it('correct key of valueOfPiletLanguage results in same value', () => {
36
- const result = valueOfPiletLanguage('ts');
36
+ const result = valueOfSourceLanguage('ts');
37
37
  expect(result).toBe(SourceLanguage.ts);
38
38
  });
39
39
 
40
40
  it('incorrect key of valueOfPiletLanguage results in value for TS', () => {
41
- const result = valueOfPiletLanguage('foo');
41
+ const result = valueOfSourceLanguage('foo');
42
42
  expect(result).toBe(SourceLanguage.ts);
43
43
  });
44
44
  });
package/src/helpers.ts CHANGED
@@ -15,7 +15,7 @@ export const publishModeKeys: Array<PiletPublishScheme> = ['none', 'basic', 'bea
15
15
  export const fromKeys: Array<PiletPublishSource> = ['local', 'remote', 'npm'];
16
16
  export const piralBuildTypeKeys: Array<PiralBuildType> = ['all', 'release', 'emulator', 'emulator-sources'];
17
17
  export const piletBuildTypeKeys: Array<PiletBuildType> = ['default', 'standalone', 'manifest'];
18
- export const clientTypeKeys: Array<NpmClientType> = ['npm', 'pnpm', 'yarn', 'lerna', 'rush'];
18
+ export const clientTypeKeys: Array<NpmClientType> = ['npm', 'pnpm', 'pnp', 'yarn', 'lerna', 'rush'];
19
19
  export const bundlerKeys: Array<string> = ['none', ...bundlerNames];
20
20
  export const availableBundlers: Array<string> = [];
21
21
  export const availableReleaseProviders: Array<string> = [];
@@ -42,10 +42,10 @@ export function keyOfForceOverwrite(value: ForceOverwrite) {
42
42
  return forceOverwriteKeys[0];
43
43
  }
44
44
 
45
- export const piletLanguageKeys = Object.keys(SourceLanguage).filter((m) => typeof SourceLanguage[m] === 'number');
45
+ export const sourceLanguageKeys = Object.keys(SourceLanguage).filter((m) => typeof SourceLanguage[m] === 'number');
46
46
 
47
- export function valueOfPiletLanguage(key: string): SourceLanguage {
48
- for (const piletLanguageKey of piletLanguageKeys) {
47
+ export function valueOfSourceLanguage(key: string): SourceLanguage {
48
+ for (const piletLanguageKey of sourceLanguageKeys) {
49
49
  if (piletLanguageKey === key) {
50
50
  return SourceLanguage[piletLanguageKey];
51
51
  }
@@ -54,12 +54,12 @@ export function valueOfPiletLanguage(key: string): SourceLanguage {
54
54
  return SourceLanguage.ts;
55
55
  }
56
56
 
57
- export function keyOfPiletLanguage(value: SourceLanguage) {
58
- for (const piletLanguageKey of piletLanguageKeys) {
57
+ export function keyOfSourceLanguage(value: SourceLanguage) {
58
+ for (const piletLanguageKey of sourceLanguageKeys) {
59
59
  if (SourceLanguage[piletLanguageKey] === value) {
60
60
  return piletLanguageKey;
61
61
  }
62
62
  }
63
63
 
64
- return piletLanguageKeys[0];
64
+ return sourceLanguageKeys[0];
65
65
  }
@@ -1,6 +1,6 @@
1
1
  import { EventEmitter } from 'events';
2
2
  import { KrasRequest } from 'kras';
3
- import PiletInjector from './pilet';
3
+ import PiletInjector from './pilet-injector';
4
4
 
5
5
  const optionsMock = {
6
6
  pilets: [],
@@ -9,6 +9,9 @@ const optionsMock = {
9
9
  api: '',
10
10
  app: '',
11
11
  active: true,
12
+ publicUrl: '/',
13
+ meta: '',
14
+ headers: {},
12
15
  };
13
16
 
14
17
  const configMock: any = {
@@ -89,6 +92,9 @@ describe('Piral-CLI piral injector', () => {
89
92
  publicUrl: '/',
90
93
  api: 'http://someFakeApi:1234',
91
94
  app: '',
95
+ publicUrl: '/',
96
+ meta: '',
97
+ headers: {},
92
98
  active: true,
93
99
  };
94
100
 
@@ -118,6 +124,9 @@ describe('Piral-CLI piral injector', () => {
118
124
  publicUrl: '/',
119
125
  api: 'http://someFakeApi:1234',
120
126
  app: '',
127
+ publicUrl: '/',
128
+ meta: '',
129
+ headers: {},
121
130
  active: true,
122
131
  };
123
132
  const core = new EventEmitter();
@@ -24,6 +24,7 @@ export interface PiletInjectorConfig extends KrasInjectorConfig {
24
24
  api: string;
25
25
  app: string;
26
26
  feed?: string;
27
+ headers: Record<string, string>;
27
28
  }
28
29
 
29
30
  interface PiletMetadata {
@@ -79,40 +80,44 @@ export default class PiletInjector implements KrasInjector {
79
80
 
80
81
  constructor(options: PiletInjectorConfig, config: KrasConfiguration, core: EventEmitter) {
81
82
  this.config = options;
82
- // either take a full URI or make it an absolute path relative to the current origin
83
- this.piletApi = /^https?:/.test(options.api)
84
- ? options.api
85
- : `${config.ssl ? 'https' : 'http'}://${host}:${config.port}${options.api}`;
86
-
87
- const { pilets, api, publicUrl } = options;
88
- this.indexPath = `${publicUrl}index.html`;
89
- const cbs = {};
90
-
91
- core.on('user-connected', (e) => {
92
- if (e.target === '*' && e.url === api.substring(1)) {
93
- cbs[e.id] = (msg: string) => e.ws.send(msg);
94
- }
95
- });
96
83
 
97
- core.on('user-disconnected', (e) => {
98
- delete cbs[e.id];
99
- });
84
+ if (this.config.active) {
85
+ // either take a full URI or make it an absolute path relative to the current origin
86
+ this.piletApi = /^https?:/.test(options.api)
87
+ ? options.api
88
+ : `${config.ssl ? 'https' : 'http'}://${host}:${config.port}${options.api}`;
100
89
 
101
- pilets.forEach((p, i) =>
102
- p.bundler.on(() => {
103
- const basePath = `${this.piletApi}/${i}/`;
104
- const meta = fillPiletMeta(p, basePath, options.meta);
90
+ const { pilets, api, publicUrl } = options;
91
+ this.indexPath = `${publicUrl}index.html`;
92
+ const cbs = {};
105
93
 
106
- for (const id of Object.keys(cbs)) {
107
- cbs[id](meta);
94
+ core.on('user-connected', (e) => {
95
+ if (e.target === '*' && e.url === api.substring(1)) {
96
+ cbs[e.id] = (msg: string) => e.ws.send(msg);
108
97
  }
109
- }),
110
- );
98
+ });
99
+
100
+ core.on('user-disconnected', (e) => {
101
+ delete cbs[e.id];
102
+ });
103
+
104
+ pilets.forEach((p, i) =>
105
+ p.bundler.on(() => {
106
+ const basePath = `${this.piletApi}/${i}/`;
107
+ const meta = fillPiletMeta(p, basePath, options.meta);
108
+
109
+ for (const id of Object.keys(cbs)) {
110
+ cbs[id](meta);
111
+ }
112
+ }),
113
+ );
114
+ }
111
115
  }
112
116
 
113
117
  get active() {
114
118
  return this.config.active;
115
119
  }
120
+
116
121
  set active(value) {
117
122
  this.config.active = value;
118
123
  }
@@ -159,9 +164,12 @@ export default class PiletInjector implements KrasInjector {
159
164
  }
160
165
 
161
166
  sendContent(content: Buffer | string, type: string, url: string): KrasResponse {
167
+ const { headers } = this.config;
168
+
162
169
  return {
163
170
  injector: { name: this.name },
164
171
  headers: {
172
+ ...headers,
165
173
  'content-type': type,
166
174
  'cache-control': 'no-cache, no-store, must-revalidate',
167
175
  pragma: 'no-cache',
@@ -1,4 +1,4 @@
1
- import PiralInjector from './piral';
1
+ import PiralInjector from './piral-injector';
2
2
  import { KrasRequest, KrasResult } from 'kras';
3
3
  import { EventEmitter } from 'events';
4
4
 
@@ -37,6 +37,7 @@ describe('Piral-CLI piral injector', () => {
37
37
  bundler,
38
38
  publicUrl: '/',
39
39
  active: true,
40
+ headers: {},
40
41
  };
41
42
  const injector = new PiralInjector(config, undefined, new EventEmitter());
42
43
  expect(injector.active).toBeTruthy();
@@ -48,6 +49,7 @@ describe('Piral-CLI piral injector', () => {
48
49
  bundler: bundlerMock,
49
50
  publicUrl: '/',
50
51
  active: true,
52
+ headers: {},
51
53
  };
52
54
  const injector = new PiralInjector(config, undefined, new EventEmitter());
53
55
 
@@ -67,6 +69,7 @@ describe('Piral-CLI piral injector', () => {
67
69
  bundler: bundlerMock,
68
70
  publicUrl: '/',
69
71
  active: true,
72
+ headers: {},
70
73
  };
71
74
  const injector = new PiralInjector(config, undefined, new EventEmitter());
72
75
 
@@ -83,6 +86,7 @@ describe('Piral-CLI piral injector', () => {
83
86
  bundler: bundlerMock,
84
87
  publicUrl: '/',
85
88
  active: true,
89
+ headers: {},
86
90
  };
87
91
  const injector = new PiralInjector(config, undefined, new EventEmitter());
88
92
  const request: KrasRequest = {
@@ -14,6 +14,7 @@ export interface PiralInjectorConfig extends KrasInjectorConfig {
14
14
  bundler: Bundler;
15
15
  publicUrl: string;
16
16
  feed?: string;
17
+ headers: Record<string, string>;
17
18
  }
18
19
 
19
20
  export default class PiralInjector implements KrasInjector {
@@ -21,29 +22,33 @@ export default class PiralInjector implements KrasInjector {
21
22
 
22
23
  constructor(options: PiralInjectorConfig, _config: KrasConfiguration, core: EventEmitter) {
23
24
  this.config = options;
24
- const api = '/$events';
25
- const cbs = {};
26
25
 
27
- core.on('user-connected', (e) => {
28
- if (e.target === '*' && e.url === api.substring(1)) {
29
- cbs[e.id] = (msg: string) => e.ws.send(msg);
30
- }
31
- });
32
-
33
- core.on('user-disconnected', (e) => {
34
- delete cbs[e.id];
35
- });
36
-
37
- this.config.bundler.on((args) => {
38
- for (const id of Object.keys(cbs)) {
39
- cbs[id](JSON.stringify(args));
40
- }
41
- });
26
+ if (this.config.active) {
27
+ const api = '/$events';
28
+ const cbs = {};
29
+
30
+ core.on('user-connected', (e) => {
31
+ if (e.target === '*' && e.url === api.substring(1)) {
32
+ cbs[e.id] = (msg: string) => e.ws.send(msg);
33
+ }
34
+ });
35
+
36
+ core.on('user-disconnected', (e) => {
37
+ delete cbs[e.id];
38
+ });
39
+
40
+ this.config.bundler.on((args) => {
41
+ for (const id of Object.keys(cbs)) {
42
+ cbs[id](JSON.stringify(args));
43
+ }
44
+ });
45
+ }
42
46
  }
43
47
 
44
48
  get active() {
45
49
  return this.config.active;
46
50
  }
51
+
47
52
  set active(value) {
48
53
  this.config.active = value;
49
54
  }
@@ -59,9 +64,11 @@ export default class PiralInjector implements KrasInjector {
59
64
  setOptions() {}
60
65
 
61
66
  sendContent(content: Buffer | string, type: string, url: string): KrasResponse {
67
+ const { headers } = this.config;
62
68
  return {
63
69
  injector: { name: this.name },
64
70
  headers: {
71
+ ...headers,
65
72
  'content-type': type,
66
73
  'cache-control': 'no-cache, no-store, must-revalidate',
67
74
  pragma: 'no-cache',
package/src/messages.ts CHANGED
@@ -953,6 +953,41 @@ export function cannotFindFile_0046(file: string): QuickMessage {
953
953
  return [LogLevels.error, '0046', `The file "${file}" does not exist!`];
954
954
  }
955
955
 
956
+ /**
957
+ * @kind Warning
958
+ *
959
+ * @summary
960
+ * Reported when the provided / default port was not available.
961
+ *
962
+ * @abstract
963
+ * By default, the debug commands spawn at the port 1234. However, under certain
964
+ * circumstances (e.g., another debug command running somewhere) this port may not
965
+ * be free.
966
+ *
967
+ * The piral-cli can select a new port, which is free, however, it will still report
968
+ * a warning message in such cases. You can then always abort the current debug
969
+ * process and start a new one - either closing the other run blocking the port or
970
+ * explicitly selecting a new one using the `--port` flag.
971
+ *
972
+ * @see
973
+ * - [Port (computer networking)](https://en.wikipedia.org/wiki/Port_(computer_networking))
974
+ *
975
+ * @example
976
+ * If you start one process to debug an app shell using `piral debug` and another process
977
+ * to debug some pilet using `pilet debug` both processes would want to run on the default
978
+ * port 1234.
979
+ *
980
+ * As a mitigation you can now either be very explicit, e.g., `piral debug --port 1010` and
981
+ * `pilet debug --port 1020` or you can just drop one of the two and always only run a single
982
+ * debug process.
983
+ *
984
+ * In any case, running both without any options also works, but then a new port will be chosen.
985
+ * The output of the Piral CLI will always show you what port is currently used.
986
+ */
987
+ export function portNotFree_0047(newPort: number, oldPort: number): QuickMessage {
988
+ return [LogLevels.warning, '0047', `The selected port "${oldPort}" is already used. Changed port to "${newPort}".`];
989
+ }
990
+
956
991
  /**
957
992
  * @kind Warning
958
993
  *
@@ -2182,24 +2217,24 @@ export function publishEmulatorFilesUnexpected_0111(directory: string): QuickMes
2182
2217
  * @kind Error
2183
2218
  *
2184
2219
  * @summary
2185
- * The "xcopy" provider requires a "--fields.target" argument.
2220
+ * The "xcopy" provider requires a "--opts.target" argument.
2186
2221
  *
2187
2222
  * @abstract
2188
2223
  * The `piral publish --type release` command requires the selection of a suitable
2189
2224
  * provider for running successfully. The "xcopy" provider just copies the sources from
2190
2225
  * the output directory (source) to a specified target directory.
2191
2226
  *
2192
- * Make sure to supply the target directory via the `--fields.target` command line flag.
2227
+ * Make sure to supply the target directory via the `--opts.target` command line flag.
2193
2228
  *
2194
2229
  * @example
2195
2230
  * The following command would specify `/temp/dest` as target directory:
2196
2231
  *
2197
2232
  * ```sh
2198
- * piral publish --type release --provider xcopy --fields.target "/temp/dest"
2233
+ * piral publish --type release --provider xcopy --opts.target "/temp/dest"
2199
2234
  * ```
2200
2235
  */
2201
2236
  export function publishXcopyMissingTarget_0112(): QuickMessage {
2202
- return [LogLevels.error, '0112', `The "xcopy" provider requires a "--fields.target" argument.`];
2237
+ return [LogLevels.error, '0112', `The "xcopy" provider requires a "--opts.target" argument.`];
2203
2238
  }
2204
2239
 
2205
2240
  /**
@@ -2222,7 +2257,7 @@ export function publishXcopyMissingTarget_0112(): QuickMessage {
2222
2257
  * The following command uses the in-built "xcopy" provider for releasing to a local directory.
2223
2258
  *
2224
2259
  * ```sh
2225
- * piral publish --type release --provider xcopy --fields.target "/temp/dest"
2260
+ * piral publish --type release --provider xcopy --opts.target "/temp/dest"
2226
2261
  * ```
2227
2262
  */
2228
2263
  export function publishProviderMissing_0113(providerName: string, availableProviders: Array<string>): QuickMessage {
@@ -2243,7 +2278,7 @@ export function publishProviderMissing_0113(providerName: string, availableProvi
2243
2278
  * The following command uses the in-built "xcopy" provider for releasing to a local directory.
2244
2279
  *
2245
2280
  * ```sh
2246
- * piral publish --type release --provider xcopy --fields.target "/temp/dest"
2281
+ * piral publish --type release --provider xcopy --opts.target "/temp/dest"
2247
2282
  * ```
2248
2283
  *
2249
2284
  * The type is "release".
@@ -2256,6 +2291,58 @@ export function publishEmulatorSourcesInvalid_0114(): QuickMessage {
2256
2291
  ];
2257
2292
  }
2258
2293
 
2294
+ /**
2295
+ * @kind Error
2296
+ *
2297
+ * @summary
2298
+ * The "feed" provider requires a "--opts.url" argument.
2299
+ *
2300
+ * @abstract
2301
+ * The `piral publish --type release` command requires the selection of a suitable
2302
+ * provider for running successfully. The "feed" provider releases the files to
2303
+ * the a Piral Feed Service with the static page feature.
2304
+ *
2305
+ * Make sure to supply the URL for the feed service via the `--opts.url` command
2306
+ * line flag.
2307
+ *
2308
+ * @example
2309
+ * The following command would specify `https://feed.piral.cloud/api/v1/feed/sample/page`
2310
+ * for the feed service:
2311
+ *
2312
+ * ```sh
2313
+ * piral publish --type release --provider feed --opts.url "https://feed.piral.cloud/api/v1/feed/sample/page" --opts.apikey "foobar123"
2314
+ * ```
2315
+ */
2316
+ export function publishFeedMissingUrl_0115(): QuickMessage {
2317
+ return [LogLevels.error, '0115', `The "feed" provider requires a "--opts.url" argument.`];
2318
+ }
2319
+
2320
+ /**
2321
+ * @kind Error
2322
+ *
2323
+ * @summary
2324
+ * The "feed" provider requires a "--opts.version" argument.
2325
+ *
2326
+ * @abstract
2327
+ * The `piral publish --type release` command requires the selection of a suitable
2328
+ * provider for running successfully. The "feed" provider releases the files to
2329
+ * the a Piral Feed Service with the static page feature.
2330
+ *
2331
+ * Make sure to supply the version either explicitly via the `--opts.version` argument
2332
+ * or implicitly by having the artifacts stored in a sub-directory of the project's root,
2333
+ * which contains a package.json with the version to use.
2334
+ *
2335
+ * @example
2336
+ * The following command would specify version "1.2.3" for the feed service:
2337
+ *
2338
+ * ```sh
2339
+ * piral publish --type release --provider feed --opts.url "..." --opts.apikey "..." --opts.version "1.2.3"
2340
+ * ```
2341
+ */
2342
+ export function publishFeedMissingVersion_0116(): QuickMessage {
2343
+ return [LogLevels.error, '0116', `The "feed" provider requires either a "--opts.version" argument or a package.json with a version.`];
2344
+ }
2345
+
2259
2346
  /**
2260
2347
  * @kind Warning
2261
2348
  *