piral-cli 0.14.20 → 0.14.21-beta.4074

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 (44) hide show
  1. package/lib/apps/build-pilet.d.ts +4 -0
  2. package/lib/apps/build-pilet.js +8 -6
  3. package/lib/apps/build-pilet.js.map +1 -1
  4. package/lib/apps/debug-pilet.d.ts +10 -0
  5. package/lib/apps/debug-pilet.js +15 -7
  6. package/lib/apps/debug-pilet.js.map +1 -1
  7. package/lib/apps/new-pilet.js +4 -3
  8. package/lib/apps/new-pilet.js.map +1 -1
  9. package/lib/build/bundler-calls.d.ts +1 -1
  10. package/lib/build/run-build-pilet.js.map +1 -1
  11. package/lib/build/run-build-piral.js.map +1 -1
  12. package/lib/build/run-debug-mono-piral.js +1 -1
  13. package/lib/build/run-debug-mono-piral.js.map +1 -1
  14. package/lib/build/run-debug-pilet.js +3 -5
  15. package/lib/build/run-debug-pilet.js.map +1 -1
  16. package/lib/build/run-debug-piral.js +1 -1
  17. package/lib/build/run-debug-piral.js.map +1 -1
  18. package/lib/commands.js +12 -0
  19. package/lib/commands.js.map +1 -1
  20. package/lib/common/package.d.ts +1 -0
  21. package/lib/common/package.js +2 -1
  22. package/lib/common/package.js.map +1 -1
  23. package/lib/external/index.js +6 -2
  24. package/lib/injectors/pilet.d.ts +1 -0
  25. package/lib/injectors/pilet.js +17 -13
  26. package/lib/injectors/pilet.js.map +1 -1
  27. package/lib/types/common.d.ts +1 -0
  28. package/lib/types/public.d.ts +2 -0
  29. package/package.json +2 -2
  30. package/src/apps/build-pilet.ts +15 -6
  31. package/src/apps/debug-pilet.ts +31 -6
  32. package/src/apps/new-pilet.ts +4 -3
  33. package/src/build/bundler-calls.ts +1 -1
  34. package/src/build/run-build-pilet.ts +1 -1
  35. package/src/build/run-build-piral.ts +1 -1
  36. package/src/build/run-debug-mono-piral.ts +2 -2
  37. package/src/build/run-debug-pilet.ts +5 -5
  38. package/src/build/run-debug-piral.ts +2 -2
  39. package/src/commands.ts +12 -0
  40. package/src/common/package.test.ts +2 -0
  41. package/src/common/package.ts +2 -0
  42. package/src/injectors/pilet.ts +20 -14
  43. package/src/types/common.ts +1 -0
  44. package/src/types/public.ts +2 -0
@@ -29,6 +29,7 @@ describe('CLI package module', () => {
29
29
  it('getPiletsInfo returns pilets information about provided piralInfo', () => {
30
30
  const emptyPiletsInfo = {
31
31
  files: [],
32
+ template: 'default',
32
33
  externals: [],
33
34
  scripts: {},
34
35
  validators: {},
@@ -45,6 +46,7 @@ describe('CLI package module', () => {
45
46
  const piralInfo = {
46
47
  pilets: {
47
48
  files: ['foo.tgz', 'foo2.tgz'],
49
+ template: 'default',
48
50
  externals: [],
49
51
  scripts: {},
50
52
  validators: {},
@@ -347,6 +347,7 @@ export function getPiletsInfo(piralInfo: any): PiletsInfo {
347
347
  files = [],
348
348
  externals = [],
349
349
  scripts = {},
350
+ template = 'default',
350
351
  validators = {},
351
352
  devDependencies = {},
352
353
  preScaffold = '',
@@ -360,6 +361,7 @@ export function getPiletsInfo(piralInfo: any): PiletsInfo {
360
361
  files,
361
362
  externals,
362
363
  scripts,
364
+ template,
363
365
  validators,
364
366
  devDependencies,
365
367
  preScaffold,
@@ -10,6 +10,7 @@ import { axios, mime } from '../external';
10
10
  import { Bundler } from '../types';
11
11
 
12
12
  const { host } = config;
13
+ const indexPath = '/index.html';
13
14
 
14
15
  interface Pilet {
15
16
  bundler: Bundler;
@@ -19,6 +20,7 @@ interface Pilet {
19
20
 
20
21
  export interface PiletInjectorConfig extends KrasInjectorConfig {
21
22
  pilets: Array<Pilet>;
23
+ publicUrl: string;
22
24
  meta: string;
23
25
  api: string;
24
26
  app: string;
@@ -210,26 +212,30 @@ export default class PiletInjector implements KrasInjector {
210
212
  }
211
213
 
212
214
  handle(req: KrasRequest): KrasResponse {
213
- const { app, api } = this.config;
214
- const path = req.url.substring(1).split('?')[0];
215
+ const { app, api, publicUrl } = this.config;
215
216
 
216
217
  if (!req.target) {
217
- const target = join(app, path);
218
+ if (req.url.startsWith(publicUrl)) {
219
+ const path = req.url.substring(publicUrl.length).split('?')[0];
220
+ const target = join(app, path);
218
221
 
219
- if (existsSync(target) && statSync(target).isFile()) {
220
- if (req.url === '/index.html') {
221
- return this.sendIndexFile(target, req.url);
222
+ if (existsSync(target) && statSync(target).isFile()) {
223
+ if (req.url === indexPath) {
224
+ return this.sendIndexFile(target, req.url);
225
+ } else {
226
+ return this.sendFile(target, req.url);
227
+ }
228
+ } else if (req.url !== indexPath) {
229
+ return this.handle({
230
+ ...req,
231
+ url: indexPath,
232
+ });
222
233
  }
223
- return this.sendFile(target, req.url);
224
- } else if (req.url !== '/index.html') {
225
- return this.handle({
226
- ...req,
227
- url: '/index.html',
228
- });
229
- } else {
230
- return undefined;
231
234
  }
235
+
236
+ return undefined;
232
237
  } else if (req.target === api) {
238
+ const path = req.url.substring(1).split('?')[0];
233
239
  return this.sendResponse(path, req.url);
234
240
  }
235
241
  }
@@ -55,6 +55,7 @@ export interface TemplateFileLocation {
55
55
 
56
56
  export interface PiletsInfo {
57
57
  files: Array<string | TemplateFileLocation>;
58
+ template: string;
58
59
  externals: Array<string>;
59
60
  devDependencies: Record<string, string | true>;
60
61
  scripts: Record<string, string>;
@@ -103,6 +103,8 @@ export interface DebugPiletParameters extends BaseBundleParameters {
103
103
  externals: Array<string>;
104
104
  importmap: Array<SharedDependency>;
105
105
  targetDir: string;
106
+ outFile: string;
107
+ outDir: string;
106
108
  entryModule: string;
107
109
  logLevel: LogLevels;
108
110
  version: PiletSchemaVersion;