@appsemble/node-utils 0.20.13 → 0.20.14

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 (72) hide show
  1. package/AppsembleError.js +1 -5
  2. package/AppsembleError.js.map +1 -1
  3. package/AppsembleError.test.js +2 -4
  4. package/AppsembleError.test.js.map +1 -1
  5. package/AppsembleError.test.ts +1 -1
  6. package/README.md +4 -4
  7. package/basicAuth.js +1 -5
  8. package/basicAuth.js.map +1 -1
  9. package/basicAuth.test.js +2 -4
  10. package/basicAuth.test.js.map +1 -1
  11. package/basicAuth.test.ts +1 -1
  12. package/formData.js +5 -12
  13. package/formData.js.map +1 -1
  14. package/formData.test.js +9 -11
  15. package/formData.test.js.map +1 -1
  16. package/formData.test.ts +1 -1
  17. package/fs.d.ts +2 -1
  18. package/fs.js +35 -65
  19. package/fs.js.map +1 -1
  20. package/fs.test.js +32 -34
  21. package/fs.test.js.map +1 -1
  22. package/fs.test.ts +6 -6
  23. package/fs.ts +12 -9
  24. package/getWorkspaces.js +6 -13
  25. package/getWorkspaces.js.map +1 -1
  26. package/handleError.js +6 -10
  27. package/handleError.js.map +1 -1
  28. package/handleError.test.js +13 -15
  29. package/handleError.test.js.map +1 -1
  30. package/handleError.test.ts +7 -7
  31. package/handleError.ts +2 -2
  32. package/index.d.ts +11 -11
  33. package/index.js +11 -27
  34. package/index.js.map +1 -1
  35. package/index.ts +11 -11
  36. package/interceptors.js +17 -27
  37. package/interceptors.js.map +1 -1
  38. package/interceptors.test.js +30 -40
  39. package/interceptors.test.js.map +1 -1
  40. package/interceptors.test.ts +7 -13
  41. package/interceptors.ts +1 -1
  42. package/jest.config.js +3 -1
  43. package/jest.setup.js +4 -6
  44. package/jest.setup.js.map +1 -1
  45. package/jest.setup.ts +3 -3
  46. package/logger.js +27 -35
  47. package/logger.js.map +1 -1
  48. package/logger.test.js +15 -17
  49. package/logger.test.js.map +1 -1
  50. package/logger.test.ts +1 -1
  51. package/loggerMiddleware.js +18 -25
  52. package/loggerMiddleware.js.map +1 -1
  53. package/loggerMiddleware.test.js +42 -52
  54. package/loggerMiddleware.test.js.map +1 -1
  55. package/loggerMiddleware.test.ts +15 -21
  56. package/loggerMiddleware.ts +1 -1
  57. package/package.json +7 -8
  58. package/readFileOrString.js +5 -9
  59. package/readFileOrString.js.map +1 -1
  60. package/readFileOrString.test.js +4 -6
  61. package/readFileOrString.test.js.map +1 -1
  62. package/readFileOrString.test.ts +2 -2
  63. package/readFileOrString.ts +1 -1
  64. package/testFixtures.d.ts +5 -4
  65. package/testFixtures.js +13 -24
  66. package/testFixtures.js.map +1 -1
  67. package/testFixtures.ts +9 -9
  68. package/tsconfig.json +1 -1
  69. package/__mocks__/os.d.ts +0 -5
  70. package/__mocks__/os.js +0 -8
  71. package/__mocks__/os.js.map +0 -1
  72. package/__mocks__/os.ts +0 -10
package/fs.test.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { AppsembleError, isErrno, opendirSafe, readData, resolveFixture } from '.';
1
+ import { AppsembleError, isErrno, opendirSafe, readData, resolveFixture } from './index.js';
2
2
 
3
3
  describe('isErrno', () => {
4
4
  it('should return false for null', () => {
@@ -55,7 +55,7 @@ describe('readData', () => {
55
55
 
56
56
  describe('opendirSafe', () => {
57
57
  it('should read a directory', async () => {
58
- const onFile = jest.fn();
58
+ const onFile = import.meta.jest.fn();
59
59
  await opendirSafe(resolveFixture('test'), onFile);
60
60
  expect(onFile).toHaveBeenCalledTimes(3);
61
61
  expect(onFile).toHaveBeenCalledWith(
@@ -73,7 +73,7 @@ describe('opendirSafe', () => {
73
73
  });
74
74
 
75
75
  it('should read a directory recursively if specified', async () => {
76
- const onFile = jest.fn();
76
+ const onFile = import.meta.jest.fn();
77
77
  await opendirSafe(resolveFixture('test'), onFile, { recursive: true });
78
78
  expect(onFile).toHaveBeenCalledTimes(5);
79
79
  expect(onFile).toHaveBeenCalledWith(
@@ -100,21 +100,21 @@ describe('opendirSafe', () => {
100
100
 
101
101
  it('should throw if the path is not a directory', async () => {
102
102
  const path = resolveFixture('hello.txt');
103
- await expect(opendirSafe(path, jest.fn())).rejects.toThrow(
103
+ await expect(opendirSafe(path, import.meta.jest.fn())).rejects.toThrow(
104
104
  new AppsembleError(`Expected ${path} to be a directory`),
105
105
  );
106
106
  });
107
107
 
108
108
  it('should throw if the path doesn’t exist', async () => {
109
109
  const path = resolveFixture('non-existent');
110
- await expect(opendirSafe(path, jest.fn())).rejects.toThrow(
110
+ await expect(opendirSafe(path, import.meta.jest.fn())).rejects.toThrow(
111
111
  new AppsembleError(`Expected ${path} to be a directory`),
112
112
  );
113
113
  });
114
114
 
115
115
  it('should not throw if the path doesn’t exist and allowMissing is true', async () => {
116
116
  const path = resolveFixture('non-existent');
117
- const result = await opendirSafe(path, jest.fn(), { allowMissing: true });
117
+ const result = await opendirSafe(path, import.meta.jest.fn(), { allowMissing: true });
118
118
  expect(result).toBeUndefined();
119
119
  });
120
120
  });
package/fs.ts CHANGED
@@ -8,7 +8,7 @@ import sortKeys from 'sort-keys';
8
8
  import { Promisable } from 'type-fest';
9
9
  import { parse, stringify } from 'yaml';
10
10
 
11
- import { AppsembleError } from '.';
11
+ import { AppsembleError } from './index.js';
12
12
 
13
13
  /**
14
14
  * Test if the error is a NodeJS errno exception.
@@ -34,9 +34,9 @@ export function isErrno(error: unknown, code?: string): error is NodeJS.ErrnoExc
34
34
  * @param path The path to the file to read.
35
35
  * @returns A tuple of the parsed content and the content as a string.
36
36
  */
37
- export async function readData<R>(path: string): Promise<[R, string]> {
37
+ export async function readData<R>(path: URL | string): Promise<[R, string]> {
38
38
  let content: string;
39
- const ext = extname(path);
39
+ const ext = extname(String(path));
40
40
  try {
41
41
  content = await readFile(path, 'utf8');
42
42
  } catch {
@@ -87,16 +87,19 @@ export async function writeData(
87
87
  const sorted = sort ? sortKeys(data, { deep: true, compare: compare || undefined }) : data;
88
88
  let buffer: string;
89
89
  try {
90
- const { format, getFileInfo, resolveConfig } = await import('prettier');
91
- const { inferredParser } = await getFileInfo(path, { resolveConfig: true });
92
- const prettierOptions = await resolveConfig(path, { editorconfig: true });
90
+ const { default: prettier } = await import('prettier');
91
+ const { inferredParser } = await prettier.getFileInfo(path, { resolveConfig: true });
92
+ const prettierOptions = await prettier.resolveConfig(path, { editorconfig: true });
93
93
  prettierOptions.parser = inferredParser;
94
- buffer = inferredParser === 'yaml' ? stringify(sorted) : JSON.stringify(sorted, undefined, 2);
95
- buffer = format(buffer, prettierOptions);
94
+ buffer =
95
+ inferredParser === 'yaml' ? stringify(sorted) : `${JSON.stringify(sorted, undefined, 2)}\n`;
96
+ buffer = prettier.format(buffer, prettierOptions);
96
97
  } catch {
97
98
  const ext = extname(path);
98
99
  buffer =
99
- ext === '.yml' || ext === '.yaml' ? stringify(sorted) : JSON.stringify(sorted, undefined, 2);
100
+ ext === '.yml' || ext === '.yaml'
101
+ ? stringify(sorted)
102
+ : `${JSON.stringify(sorted, undefined, 2)}\n`;
100
103
  }
101
104
  await mkdir(dirname(path), { recursive: true });
102
105
  await writeFile(path, buffer);
package/getWorkspaces.js CHANGED
@@ -1,12 +1,6 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getWorkspaces = void 0;
7
- const promises_1 = require("fs/promises");
8
- const path_1 = require("path");
9
- const fast_glob_1 = __importDefault(require("fast-glob"));
1
+ import { readFile } from 'fs/promises';
2
+ import { join } from 'path';
3
+ import fg from 'fast-glob';
10
4
  /**
11
5
  * Discover Appsemble blocks based on workspaces in a monorepo.
12
6
  *
@@ -15,9 +9,9 @@ const fast_glob_1 = __importDefault(require("fast-glob"));
15
9
  * @param cwd The project root in which to find workspaces.
16
10
  * @returns Discovered Appsemble blocks.
17
11
  */
18
- async function getWorkspaces(cwd) {
19
- const { workspaces = [] } = JSON.parse(await (0, promises_1.readFile)((0, path_1.join)(cwd, 'package.json'), 'utf8'));
20
- const dirs = await (0, fast_glob_1.default)(workspaces, {
12
+ export async function getWorkspaces(cwd) {
13
+ const { workspaces = [] } = JSON.parse(await readFile(join(cwd, 'package.json'), 'utf8'));
14
+ const dirs = await fg(workspaces, {
21
15
  cwd,
22
16
  absolute: true,
23
17
  followSymbolicLinks: true,
@@ -25,5 +19,4 @@ async function getWorkspaces(cwd) {
25
19
  });
26
20
  return dirs.sort();
27
21
  }
28
- exports.getWorkspaces = getWorkspaces;
29
22
  //# sourceMappingURL=getWorkspaces.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getWorkspaces.js","sourceRoot":"","sources":["getWorkspaces.ts"],"names":[],"mappings":";;;;;;AAAA,0CAAuC;AACvC,+BAA4B;AAE5B,0DAA2B;AAE3B;;;;;;;GAOG;AACI,KAAK,UAAU,aAAa,CAAC,GAAW;IAC7C,MAAM,EAAE,UAAU,GAAG,EAAE,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,IAAA,mBAAQ,EAAC,IAAA,WAAI,EAAC,GAAG,EAAE,cAAc,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;IAC1F,MAAM,IAAI,GAAG,MAAM,IAAA,mBAAE,EAAC,UAAU,EAAE;QAChC,GAAG;QACH,QAAQ,EAAE,IAAI;QACd,mBAAmB,EAAE,IAAI;QACzB,eAAe,EAAE,IAAI;KACtB,CAAC,CAAC;IACH,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;AACrB,CAAC;AATD,sCASC"}
1
+ {"version":3,"file":"getWorkspaces.js","sourceRoot":"","sources":["getWorkspaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,OAAO,EAAE,MAAM,WAAW,CAAC;AAE3B;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,GAAW;IAC7C,MAAM,EAAE,UAAU,GAAG,EAAE,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;IAC1F,MAAM,IAAI,GAAG,MAAM,EAAE,CAAC,UAAU,EAAE;QAChC,GAAG;QACH,QAAQ,EAAE,IAAI;QACd,mBAAmB,EAAE,IAAI;QACzB,eAAe,EAAE,IAAI;KACtB,CAAC,CAAC;IACH,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;AACrB,CAAC"}
package/handleError.js CHANGED
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.handleError = void 0;
4
- const AppsembleError_1 = require("./AppsembleError");
5
- const logger_1 = require("./logger");
1
+ import { AppsembleError } from './AppsembleError.js';
2
+ import { logger } from './logger.js';
6
3
  /**
7
4
  * Handle a fatal error.
8
5
  *
@@ -12,19 +9,18 @@ const logger_1 = require("./logger");
12
9
  * @param error The error that was thrown.
13
10
  * @param yargs The active yargs instance.
14
11
  */
15
- function handleError(message, error, yargs) {
12
+ export function handleError(message, error, yargs) {
16
13
  if (typeof message === 'string') {
17
14
  yargs.showHelp();
18
15
  // eslint-disable-next-line no-console
19
16
  console.error(message);
20
17
  }
21
- else if (error instanceof AppsembleError_1.AppsembleError) {
22
- logger_1.logger.error(error.message);
18
+ else if (error instanceof AppsembleError) {
19
+ logger.error(error.message);
23
20
  }
24
21
  else {
25
- logger_1.logger.error(error);
22
+ logger.error(error);
26
23
  }
27
24
  process.exit(1);
28
25
  }
29
- exports.handleError = handleError;
30
26
  //# sourceMappingURL=handleError.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"handleError.js","sourceRoot":"","sources":["handleError.ts"],"names":[],"mappings":";;;AAEA,qDAAkD;AAClD,qCAAkC;AAElC;;;;;;;;GAQG;AACH,SAAgB,WAAW,CAAC,OAAe,EAAE,KAAY,EAAE,KAAW;IACpE,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;QAC/B,KAAK,CAAC,QAAQ,EAAE,CAAC;QACjB,sCAAsC;QACtC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;KACxB;SAAM,IAAI,KAAK,YAAY,+BAAc,EAAE;QAC1C,eAAM,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;KAC7B;SAAM;QACL,eAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;KACrB;IACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAXD,kCAWC"}
1
+ {"version":3,"file":"handleError.js","sourceRoot":"","sources":["handleError.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC;;;;;;;;GAQG;AACH,MAAM,UAAU,WAAW,CAAC,OAAe,EAAE,KAAY,EAAE,KAAW;IACpE,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;QAC/B,KAAK,CAAC,QAAQ,EAAE,CAAC;QACjB,sCAAsC;QACtC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;KACxB;SAAM,IAAI,KAAK,YAAY,cAAc,EAAE;QAC1C,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;KAC7B;SAAM;QACL,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;KACrB;IACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC"}
@@ -1,34 +1,32 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const AppsembleError_1 = require("./AppsembleError");
4
- const handleError_1 = require("./handleError");
5
- const logger_1 = require("./logger");
1
+ import { AppsembleError } from './AppsembleError.js';
2
+ import { handleError } from './handleError.js';
3
+ import { logger } from './logger.js';
6
4
  let yargs;
7
5
  beforeEach(() => {
8
- yargs = { showHelp: jest.fn() };
9
- jest.spyOn(console, 'error').mockImplementation();
10
- jest.spyOn(process, 'exit').mockImplementation();
11
- jest.spyOn(logger_1.logger, 'error').mockImplementation();
6
+ yargs = { showHelp: import.meta.jest.fn() };
7
+ import.meta.jest.spyOn(console, 'error').mockImplementation();
8
+ import.meta.jest.spyOn(process, 'exit').mockImplementation();
9
+ import.meta.jest.spyOn(logger, 'error').mockImplementation();
12
10
  });
13
11
  it('should show the help message if it is passed a yargs message', () => {
14
- (0, handleError_1.handleError)('Command foo not found', undefined, yargs);
12
+ handleError('Command foo not found', undefined, yargs);
15
13
  // eslint-disable-next-line no-console
16
14
  expect(console.error).toHaveBeenCalledWith('Command foo not found');
17
15
  expect(yargs.showHelp).toHaveBeenCalledWith();
18
- expect(logger_1.logger.error).not.toHaveBeenCalled();
16
+ expect(logger.error).not.toHaveBeenCalled();
19
17
  expect(process.exit).toHaveBeenCalledWith(1);
20
18
  });
21
19
  it('should log the message of an Appsemble error', () => {
22
- (0, handleError_1.handleError)(undefined, new AppsembleError_1.AppsembleError('Oh noez!'), yargs);
20
+ handleError(undefined, new AppsembleError('Oh noez!'), yargs);
23
21
  expect(yargs.showHelp).not.toHaveBeenCalled();
24
- expect(logger_1.logger.error).toHaveBeenCalledWith('Oh noez!');
22
+ expect(logger.error).toHaveBeenCalledWith('Oh noez!');
25
23
  expect(process.exit).toHaveBeenCalledWith(1);
26
24
  });
27
25
  it('should log unknown errors raw', () => {
28
26
  const error = new Error('Oh noez!');
29
- (0, handleError_1.handleError)(undefined, error, yargs);
27
+ handleError(undefined, error, yargs);
30
28
  expect(yargs.showHelp).not.toHaveBeenCalled();
31
- expect(logger_1.logger.error).toHaveBeenCalledWith(error);
29
+ expect(logger.error).toHaveBeenCalledWith(error);
32
30
  expect(process.exit).toHaveBeenCalledWith(1);
33
31
  });
34
32
  //# sourceMappingURL=handleError.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"handleError.test.js","sourceRoot":"","sources":["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,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC;AAC/C,CAAC,CAAC,CAAC"}
@@ -1,16 +1,16 @@
1
1
  import { Argv } from 'yargs';
2
2
 
3
- import { AppsembleError } from './AppsembleError';
4
- import { handleError } from './handleError';
5
- import { logger } from './logger';
3
+ import { AppsembleError } from './AppsembleError.js';
4
+ import { handleError } from './handleError.js';
5
+ import { logger } from './logger.js';
6
6
 
7
7
  let yargs: Argv;
8
8
 
9
9
  beforeEach(() => {
10
- yargs = { showHelp: jest.fn() } as Partial<Argv> as Argv;
11
- jest.spyOn(console, 'error').mockImplementation();
12
- jest.spyOn(process, 'exit').mockImplementation();
13
- jest.spyOn(logger, 'error').mockImplementation();
10
+ yargs = { showHelp: import.meta.jest.fn() } as Partial<Argv> as Argv;
11
+ import.meta.jest.spyOn(console, 'error').mockImplementation();
12
+ import.meta.jest.spyOn(process, 'exit').mockImplementation();
13
+ import.meta.jest.spyOn(logger, 'error').mockImplementation();
14
14
  });
15
15
 
16
16
  it('should show the help message if it is passed a yargs message', () => {
package/handleError.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Argv } from 'yargs';
2
2
 
3
- import { AppsembleError } from './AppsembleError';
4
- import { logger } from './logger';
3
+ import { AppsembleError } from './AppsembleError.js';
4
+ import { logger } from './logger.js';
5
5
 
6
6
  /**
7
7
  * Handle a fatal error.
package/index.d.ts CHANGED
@@ -1,11 +1,11 @@
1
- export * from './logger';
2
- export * from './AppsembleError';
3
- export * from './basicAuth';
4
- export * from './formData';
5
- export * from './getWorkspaces';
6
- export * from './handleError';
7
- export * from './interceptors';
8
- export * from './loggerMiddleware';
9
- export * from './readFileOrString';
10
- export * from './fs';
11
- export * from './testFixtures';
1
+ export * from './AppsembleError.js';
2
+ export * from './basicAuth.js';
3
+ export * from './formData.js';
4
+ export * from './fs.js';
5
+ export * from './getWorkspaces.js';
6
+ export * from './handleError.js';
7
+ export * from './interceptors.js';
8
+ export * from './logger.js';
9
+ export * from './loggerMiddleware.js';
10
+ export * from './readFileOrString.js';
11
+ export * from './testFixtures.js';
package/index.js CHANGED
@@ -1,28 +1,12 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./logger"), exports);
18
- __exportStar(require("./AppsembleError"), exports);
19
- __exportStar(require("./basicAuth"), exports);
20
- __exportStar(require("./formData"), exports);
21
- __exportStar(require("./getWorkspaces"), exports);
22
- __exportStar(require("./handleError"), exports);
23
- __exportStar(require("./interceptors"), exports);
24
- __exportStar(require("./loggerMiddleware"), exports);
25
- __exportStar(require("./readFileOrString"), exports);
26
- __exportStar(require("./fs"), exports);
27
- __exportStar(require("./testFixtures"), exports);
1
+ export * from './AppsembleError.js';
2
+ export * from './basicAuth.js';
3
+ export * from './formData.js';
4
+ export * from './fs.js';
5
+ export * from './getWorkspaces.js';
6
+ export * from './handleError.js';
7
+ export * from './interceptors.js';
8
+ export * from './logger.js';
9
+ export * from './loggerMiddleware.js';
10
+ export * from './readFileOrString.js';
11
+ export * from './testFixtures.js';
28
12
  //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,mDAAiC;AACjC,8CAA4B;AAC5B,6CAA2B;AAC3B,kDAAgC;AAChC,gDAA8B;AAC9B,iDAA+B;AAC/B,qDAAmC;AACnC,qDAAmC;AACnC,uCAAqB;AACrB,iDAA+B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC"}
package/index.ts CHANGED
@@ -1,11 +1,11 @@
1
- export * from './logger';
2
- export * from './AppsembleError';
3
- export * from './basicAuth';
4
- export * from './formData';
5
- export * from './getWorkspaces';
6
- export * from './handleError';
7
- export * from './interceptors';
8
- export * from './loggerMiddleware';
9
- export * from './readFileOrString';
10
- export * from './fs';
11
- export * from './testFixtures';
1
+ export * from './AppsembleError.js';
2
+ export * from './basicAuth.js';
3
+ export * from './formData.js';
4
+ export * from './fs.js';
5
+ export * from './getWorkspaces.js';
6
+ export * from './handleError.js';
7
+ export * from './interceptors.js';
8
+ export * from './logger.js';
9
+ export * from './loggerMiddleware.js';
10
+ export * from './readFileOrString.js';
11
+ export * from './testFixtures.js';
package/interceptors.js CHANGED
@@ -1,14 +1,8 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.configureAxios = exports.responseLogger = exports.requestLogger = exports.formData = void 0;
7
- const os_1 = require("os");
8
- const axios_1 = __importDefault(require("axios"));
9
- const cli_highlight_1 = require("cli-highlight");
10
- const form_data_1 = __importDefault(require("form-data"));
11
- const logger_1 = require("./logger");
1
+ import { arch, type } from 'os';
2
+ import axios from 'axios';
3
+ import { highlight } from 'cli-highlight';
4
+ import FormData from 'form-data';
5
+ import { logger } from './logger.js';
12
6
  /**
13
7
  * This is used to set a request id, so the request and response can be matched in the logs.
14
8
  */
@@ -19,42 +13,39 @@ const id = Symbol('id');
19
13
  * @param config The axios request configuration.
20
14
  * @returns The config with additional `multipart/form-data` headers if appropriate.
21
15
  */
22
- function formData(config) {
23
- if (config.data instanceof form_data_1.default) {
16
+ export function formData(config) {
17
+ if (config.data instanceof FormData) {
24
18
  Object.assign(config.headers, config.data.getHeaders());
25
19
  }
26
20
  return config;
27
21
  }
28
- exports.formData = formData;
29
22
  /**
30
23
  * An {@link axios} request interceptor to log requests.
31
24
  *
32
25
  * @param config The axios request configuration.
33
26
  * @returns The original config.
34
27
  */
35
- function requestLogger(config) {
28
+ export function requestLogger(config) {
36
29
  const time = Date.now();
37
- logger_1.logger.verbose(`> ${time} ${(0, cli_highlight_1.highlight)(`${config.method.toUpperCase()} ${axios_1.default.getUri(config)} HTTP/1.1`, {
30
+ logger.verbose(`> ${time} ${highlight(`${config.method.toUpperCase()} ${axios.getUri(config)} HTTP/1.1`, {
38
31
  language: 'http',
39
32
  })}`);
40
33
  // eslint-disable-next-line no-param-reassign
41
34
  config[id] = time;
42
35
  return config;
43
36
  }
44
- exports.requestLogger = requestLogger;
45
37
  /**
46
38
  * An {@link axios} response interceptor to log responses.
47
39
  *
48
40
  * @param response The axios response.
49
41
  * @returns The original response.
50
42
  */
51
- function responseLogger(response) {
52
- logger_1.logger.verbose(`< ${response.config[id]} ${(0, cli_highlight_1.highlight)(`HTTP/1.1 ${response.status} ${response.statusText}`, {
43
+ export function responseLogger(response) {
44
+ logger.verbose(`< ${response.config[id]} ${highlight(`HTTP/1.1 ${response.status} ${response.statusText}`, {
53
45
  language: 'http',
54
46
  })}`);
55
47
  return response;
56
48
  }
57
- exports.responseLogger = responseLogger;
58
49
  /**
59
50
  * Configure the default Axios instance.
60
51
  *
@@ -63,12 +54,11 @@ exports.responseLogger = responseLogger;
63
54
  * @param name A PascalCase representation of the client.
64
55
  * @param version The version of the client to represent.
65
56
  */
66
- function configureAxios(name, version) {
67
- const ua = `${name}/${version} (${(0, os_1.type)()} ${(0, os_1.arch)()}; Node ${process.version})`;
68
- axios_1.default.defaults.headers.common['user-agent'] = ua;
69
- axios_1.default.interceptors.request.use(formData);
70
- axios_1.default.interceptors.request.use(requestLogger);
71
- axios_1.default.interceptors.response.use(responseLogger);
57
+ export function configureAxios(name, version) {
58
+ const ua = `${name}/${version} (${type()} ${arch()}; Node ${process.version})`;
59
+ axios.defaults.headers.common['user-agent'] = ua;
60
+ axios.interceptors.request.use(formData);
61
+ axios.interceptors.request.use(requestLogger);
62
+ axios.interceptors.response.use(responseLogger);
72
63
  }
73
- exports.configureAxios = configureAxios;
74
64
  //# sourceMappingURL=interceptors.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"interceptors.js","sourceRoot":"","sources":["interceptors.ts"],"names":[],"mappings":";;;;;;AAAA,2BAAgC;AAEhC,kDAAiE;AACjE,iDAA0C;AAC1C,0DAAiC;AAEjC,qCAAkC;AAElC;;GAEG;AACH,MAAM,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;AAQxB;;;;;GAKG;AACH,SAAgB,QAAQ,CAAC,MAA0B;IACjD,IAAI,MAAM,CAAC,IAAI,YAAY,mBAAQ,EAAE;QACnC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;KACzD;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AALD,4BAKC;AAED;;;;;GAKG;AACH,SAAgB,aAAa,CAAC,MAA0B;IACtD,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACxB,eAAM,CAAC,OAAO,CACZ,KAAK,IAAI,IAAI,IAAA,yBAAS,EAAC,G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cAAc,CAAC,IAAY,EAAE,OAAe;IAC1D,MAAM,EAAE,GAAG,GAAG,IAAI,IAAI,OAAO,KAAK,IAAI,EAAE,IAAI,IAAI,EAAE,UAAU,OAAO,CAAC,OAAO,GAAG,CAAC;IAC/E,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,CAAC;IAEjD,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACzC,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IAC9C,KAAK,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;AAClD,CAAC"}
@@ -1,32 +1,22 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const fake_timers_1 = require("@sinonjs/fake-timers");
7
- const axios_1 = __importDefault(require("axios"));
8
- const axios_mock_adapter_1 = __importDefault(require("axios-mock-adapter"));
9
- const cli_highlight_1 = require("cli-highlight");
10
- const form_data_1 = __importDefault(require("form-data"));
11
- const _1 = require(".");
1
+ import axios from 'axios';
2
+ import MockAdapter from 'axios-mock-adapter';
3
+ import { highlight } from 'cli-highlight';
4
+ import FormData from 'form-data';
5
+ import { configureAxios, formData, logger, requestLogger, responseLogger } from './index.js';
12
6
  function h(content) {
13
- return (0, cli_highlight_1.highlight)(content, { language: 'http' });
7
+ return highlight(content, { language: 'http' });
14
8
  }
15
9
  let instance;
16
10
  let mock;
17
- let clock;
18
- jest.mock('os');
11
+ import.meta.jest.mock('os');
19
12
  beforeEach(() => {
20
- clock = (0, fake_timers_1.install)();
21
- });
22
- afterEach(() => {
23
- clock.uninstall();
13
+ import.meta.jest.useFakeTimers({ now: 0 });
24
14
  });
25
15
  describe('formData', () => {
26
16
  beforeAll(() => {
27
- instance = axios_1.default.create();
28
- instance.interceptors.request.use(_1.formData);
29
- mock = new axios_mock_adapter_1.default(instance);
17
+ instance = axios.create();
18
+ instance.interceptors.request.use(formData);
19
+ mock = new MockAdapter(instance);
30
20
  });
31
21
  it('should add headers for form-data requests', async () => {
32
22
  let headers;
@@ -34,7 +24,7 @@ describe('formData', () => {
34
24
  ({ headers } = config);
35
25
  return [200];
36
26
  });
37
- const form = new form_data_1.default();
27
+ const form = new FormData();
38
28
  await instance.post('/', form);
39
29
  expect(headers).toHaveProperty('Content-Type', expect.stringMatching(/^multipart\/form-data; boundary=/));
40
30
  });
@@ -50,44 +40,44 @@ describe('formData', () => {
50
40
  });
51
41
  describe('requestLogger', () => {
52
42
  beforeAll(() => {
53
- instance = axios_1.default.create();
54
- instance.interceptors.request.use(_1.requestLogger);
55
- mock = new axios_mock_adapter_1.default(instance);
43
+ instance = axios.create();
44
+ instance.interceptors.request.use(requestLogger);
45
+ mock = new MockAdapter(instance);
56
46
  mock.onAny().reply(200);
57
47
  });
58
48
  it('should log requests', async () => {
59
- jest.spyOn(_1.logger, 'verbose');
49
+ import.meta.jest.spyOn(logger, 'verbose');
60
50
  await instance.get('/');
61
- expect(_1.logger.verbose).toHaveBeenCalledWith(`> 0 ${h('GET / HTTP/1.1')}`);
51
+ expect(logger.verbose).toHaveBeenCalledWith(`> 0 ${h('GET / HTTP/1.1')}`);
62
52
  });
63
53
  });
64
54
  describe('responseLogger', () => {
65
55
  beforeAll(() => {
66
- instance = axios_1.default.create();
67
- instance.interceptors.response.use(_1.responseLogger);
68
- mock = new axios_mock_adapter_1.default(instance);
56
+ instance = axios.create();
57
+ instance.interceptors.response.use(responseLogger);
58
+ mock = new MockAdapter(instance);
69
59
  mock.onAny().reply(200);
70
60
  });
71
61
  it('should log responses', async () => {
72
- jest.spyOn(_1.logger, 'verbose');
62
+ import.meta.jest.spyOn(logger, 'verbose');
73
63
  await instance.get('/');
74
- expect(_1.logger.verbose).toHaveBeenCalledWith(expect.any(String));
64
+ expect(logger.verbose).toHaveBeenCalledWith(expect.any(String));
75
65
  });
76
66
  });
77
67
  describe('configureAxios', () => {
78
68
  beforeEach(() => {
79
- jest.spyOn(axios_1.default.interceptors.request, 'use').mockImplementation();
80
- jest.spyOn(axios_1.default.interceptors.response, 'use').mockImplementation();
69
+ import.meta.jest.spyOn(axios.interceptors.request, 'use').mockImplementation();
70
+ import.meta.jest.spyOn(axios.interceptors.response, 'use').mockImplementation();
81
71
  });
82
72
  it('should set the correct user agent', () => {
83
- (0, _1.configureAxios)('TestClient', '1.2.3');
84
- expect(axios_1.default.defaults.headers.common['user-agent']).toBe(`TestClient/1.2.3 (Linux x64; Node ${process.version})`);
73
+ configureAxios('TestClient', '1.2.3');
74
+ expect(axios.defaults.headers.common['user-agent']).toBe(`TestClient/1.2.3 (Linux x64; Node ${process.version})`);
85
75
  });
86
76
  it('should apply all interceptors', () => {
87
- (0, _1.configureAxios)('TestClient', '1.2.3');
88
- expect(axios_1.default.interceptors.request.use).toHaveBeenCalledWith(_1.formData);
89
- expect(axios_1.default.interceptors.request.use).toHaveBeenCalledWith(_1.requestLogger);
90
- expect(axios_1.default.interceptors.response.use).toHaveBeenCalledWith(_1.responseLogger);
77
+ configureAxios('TestClient', '1.2.3');
78
+ expect(axios.interceptors.request.use).toHaveBeenCalledWith(formData);
79
+ expect(axios.interceptors.request.use).toHaveBeenCalledWith(requestLogger);
80
+ expect(axios.interceptors.response.use).toHaveBeenCalledWith(responseLogger);
91
81
  });
92
82
  });
93
83
  //# sourceMappingURL=interceptors.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"interceptors.test.js","sourceRoot":"","sources":["interceptors.test.ts"],"names":[],"mappings":";;;;;AAAA,sDAA+D;AAC/D,kDAA6C;AAC7C,4EAA6C;AAC7C,iDAA0C;AAC1C,0DAAiC;AAEjC,wBAAoF;AAEpF,SAAS,CAAC,CAAC,OAAe;IACxB,OAAO,IAAA,yBAAS,EAAC,OAAO,EAAE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