@build-script/package-tools 0.0.7 → 0.0.9

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 (83) hide show
  1. package/lib/commands/detect-package-change.d.ts +11 -1
  2. package/lib/commands/detect-package-change.d.ts.map +1 -1
  3. package/lib/commands/detect-package-change.js +48 -18
  4. package/lib/commands/detect-package-change.js.map +1 -1
  5. package/lib/commands/monorepo-bump-version.js +5 -5
  6. package/lib/commands/monorepo-bump-version.js.map +1 -1
  7. package/lib/commands/monorepo-cnpm-sync.js +1 -1
  8. package/lib/commands/monorepo-cnpm-sync.js.map +1 -1
  9. package/lib/commands/monorepo-link-binaries.js +4 -4
  10. package/lib/commands/monorepo-link-binaries.js.map +1 -1
  11. package/lib/commands/monorepo-list.d.ts +1 -1
  12. package/lib/commands/monorepo-list.d.ts.map +1 -1
  13. package/lib/commands/monorepo-list.js +5 -6
  14. package/lib/commands/monorepo-list.js.map +1 -1
  15. package/lib/commands/monorepo-publish.d.ts +4 -0
  16. package/lib/commands/monorepo-publish.d.ts.map +1 -1
  17. package/lib/commands/monorepo-publish.js +202 -87
  18. package/lib/commands/monorepo-publish.js.map +1 -1
  19. package/lib/commands/monorepo-tsconfig.js +1 -1
  20. package/lib/commands/monorepo-tsconfig.js.map +1 -1
  21. package/lib/commands/monorepo-upgrade.js +2 -2
  22. package/lib/commands/monorepo-upgrade.js.map +1 -1
  23. package/lib/commands/run-if-version-mismatch.js +3 -3
  24. package/lib/commands/run-if-version-mismatch.js.map +1 -1
  25. package/lib/commands/unshare-make-tarball.d.ts +19 -0
  26. package/lib/commands/unshare-make-tarball.d.ts.map +1 -0
  27. package/lib/commands/unshare-make-tarball.js +41 -0
  28. package/lib/commands/unshare-make-tarball.js.map +1 -0
  29. package/lib/commands.generated.d.ts +1 -0
  30. package/lib/commands.generated.d.ts.map +1 -1
  31. package/lib/commands.generated.js +38 -4
  32. package/lib/commands.generated.js.map +1 -1
  33. package/lib/common/cache/native.npm.d.ts +1 -0
  34. package/lib/common/cache/native.npm.d.ts.map +1 -1
  35. package/lib/common/cache/native.npm.js +8 -5
  36. package/lib/common/cache/native.npm.js.map +1 -1
  37. package/lib/common/functions/cli.d.ts +0 -1
  38. package/lib/common/functions/cli.d.ts.map +1 -1
  39. package/lib/common/functions/cli.js +2 -3
  40. package/lib/common/functions/cli.js.map +1 -1
  41. package/lib/common/package-manager/driver.abstract.d.ts +2 -2
  42. package/lib/common/package-manager/driver.abstract.d.ts.map +1 -1
  43. package/lib/common/package-manager/driver.abstract.js +10 -4
  44. package/lib/common/package-manager/driver.abstract.js.map +1 -1
  45. package/lib/common/package-manager/package-json.d.ts +1 -1
  46. package/lib/common/package-manager/package-json.d.ts.map +1 -1
  47. package/lib/common/shared-jobs/detect-change-job.d.ts +2 -1
  48. package/lib/common/shared-jobs/detect-change-job.d.ts.map +1 -1
  49. package/lib/common/shared-jobs/detect-change-job.js +6 -7
  50. package/lib/common/shared-jobs/detect-change-job.js.map +1 -1
  51. package/lib/common/taball/file-download.js +2 -2
  52. package/lib/common/taball/file-download.js.map +1 -1
  53. package/lib/common/version.generated.d.ts +1 -1
  54. package/lib/common/version.generated.js +1 -1
  55. package/lib/main.d.ts.map +1 -1
  56. package/lib/main.js +11 -2
  57. package/lib/main.js.map +1 -1
  58. package/lib/tsconfig.tsbuildinfo +1 -1
  59. package/package.json +11 -11
  60. package/src/commands/detect-package-change.ts +53 -18
  61. package/src/commands/monorepo-bump-version.ts +5 -5
  62. package/src/commands/monorepo-cnpm-sync.ts +1 -1
  63. package/src/commands/monorepo-link-binaries.ts +4 -4
  64. package/src/commands/monorepo-list.ts +5 -6
  65. package/src/commands/monorepo-publish.ts +217 -102
  66. package/src/commands/monorepo-tsconfig.ts +1 -1
  67. package/src/commands/monorepo-upgrade.ts +2 -2
  68. package/src/commands/run-if-version-mismatch.ts +3 -3
  69. package/src/commands/unshare-make-tarball.ts +46 -0
  70. package/src/commands.generated.ts +38 -4
  71. package/src/common/cache/native.npm.ts +11 -6
  72. package/src/common/functions/cli.ts +2 -3
  73. package/src/common/package-manager/driver.abstract.ts +10 -5
  74. package/src/common/package-manager/package-json.ts +1 -1
  75. package/src/common/shared-jobs/detect-change-job.ts +7 -7
  76. package/src/common/taball/file-download.ts +2 -2
  77. package/src/common/version.generated.ts +1 -1
  78. package/src/main.ts +11 -2
  79. package/lib/common/functions/global-lifecycle.d.ts +0 -5
  80. package/lib/common/functions/global-lifecycle.d.ts.map +0 -1
  81. package/lib/common/functions/global-lifecycle.js +0 -34
  82. package/lib/common/functions/global-lifecycle.js.map +0 -1
  83. package/src/common/functions/global-lifecycle.ts +0 -40
@@ -13,8 +13,8 @@ export class Command extends CommandDefine {
13
13
  }
14
14
 
15
15
  export async function main() {
16
- const dryRun = argv.flag('--dry') > 0;
17
- const skipUpdate = argv.flag('--skip-update') > 0;
16
+ const dryRun = argv.flag(['--dry']) > 0;
17
+ const skipUpdate = argv.flag(['--skip-update']) > 0;
18
18
 
19
19
  const workspace = await createWorkspace();
20
20
  const packageManager = await createPackageManager(PackageManagerUsageKind.Read, workspace);
@@ -35,9 +35,9 @@ export class Command extends CommandDefine {
35
35
  };
36
36
  }
37
37
  export async function main(argv: ArgumentTypings.IArgsReaderApi) {
38
- const noCache = argv.flag('--no-cache') > 0;
39
- const flushCache = argv.flag('--flush') > 0;
40
- const onlyNewer = argv.flag('--newer') > 0;
38
+ const noCache = argv.flag(['--no-cache']) > 0;
39
+ const flushCache = argv.flag(['--flush']) > 0;
40
+ const onlyNewer = argv.flag(['--newer']) > 0;
41
41
 
42
42
  const commands = argv.unused();
43
43
  if (commands.length === 0 || !process.argv.includes('--')) {
@@ -0,0 +1,46 @@
1
+ import { createWorkspace } from '@build-script/monorepo-lib';
2
+ import { argv, CommandDefine, logger } from '@idlebox/cli';
3
+ import { UsageError } from '@idlebox/common';
4
+ import { PackageManagerUsageKind } from '../common/package-manager/driver.abstract.js';
5
+ import { createPackageManager } from '../common/package-manager/package-manager.js';
6
+
7
+ export class Command extends CommandDefine {
8
+ protected override readonly _usage = '运行pack命令';
9
+ protected override readonly _description = '';
10
+ protected override readonly _help = '';
11
+ protected override readonly _arguments = {
12
+ '--output': {
13
+ flag: false,
14
+ description: '输出文件路径',
15
+ },
16
+ '--project': {
17
+ flag: false,
18
+ description: '要打包的项目名称',
19
+ },
20
+ };
21
+ public readonly isHidden = true;
22
+ }
23
+
24
+ export async function main() {
25
+ const workspace = await createWorkspace();
26
+ const projectName = argv.single(['--project']);
27
+ if (!projectName) {
28
+ throw new UsageError('missing --project');
29
+ }
30
+
31
+ const node = await workspace.getPackage(projectName);
32
+ if (!node) {
33
+ throw new UsageError(`unknown project: ${projectName}`);
34
+ }
35
+
36
+ const output = argv.single(['--output']);
37
+ if (!output) {
38
+ throw new UsageError(`missing --output`);
39
+ }
40
+
41
+ logger.log`unshare builder: ${node.name}`;
42
+ const pm = await createPackageManager(PackageManagerUsageKind.Read, workspace, node.absolute);
43
+ const realOut = await pm.pack(output);
44
+
45
+ console.log(realOut);
46
+ }
@@ -17,12 +17,22 @@ export const cli_commands: readonly ICommandDefineWithCommand[] = [
17
17
  {
18
18
  "command": "detect-package-change",
19
19
  "help": "",
20
- "usage": "",
20
+ "usage": "\u001b[14;3m--bump\u001b[0m \u001b[14;3m--json\u001b[0m ",
21
21
  "description": "本地运行npm pack并与npm上的最新版本对比差异",
22
22
  "args": {
23
23
  "--bump": {
24
+ "usage": true,
24
25
  "flag": true,
25
26
  "description": "当发现更改时更新package.json,增加版本号0.0.1"
27
+ },
28
+ "--json": {
29
+ "usage": true,
30
+ "flag": true,
31
+ "description": "输出JSON格式(不支持bump)"
32
+ },
33
+ "--unshare": {
34
+ "flag": false,
35
+ "description": "[linux] 在虚拟环境中运行(不支持bump),传入参数为overlay根目录"
26
36
  }
27
37
  },
28
38
  "commonArgs": {},
@@ -103,7 +113,7 @@ export const cli_commands: readonly ICommandDefineWithCommand[] = [
103
113
  {
104
114
  "command": "monorepo-list",
105
115
  "help": "",
106
- "usage": "\u001b[3;38;5;14m--verbose\u001b[0m \u001b[3;38;5;14m--json\u001b[0m \u001b[3;38;5;14m--relative\u001b[0m",
116
+ "usage": "",
107
117
  "description": "列出所有项目目录",
108
118
  "args": {
109
119
  "--verbose": {
@@ -137,8 +147,12 @@ export const cli_commands: readonly ICommandDefineWithCommand[] = [
137
147
  "description": "仅检查修改,不发布(仍会修改version字段)"
138
148
  },
139
149
  "--private": {
140
- "flag": false,
150
+ "flag": true,
141
151
  "description": "即使private=true也执行"
152
+ },
153
+ "--concurrency": {
154
+ "flag": false,
155
+ "description": "并发数(默认5)"
142
156
  }
143
157
  },
144
158
  "commonArgs": {},
@@ -217,6 +231,25 @@ export const cli_commands: readonly ICommandDefineWithCommand[] = [
217
231
  "commonArgs": {},
218
232
  "positional": false,
219
233
  "isHidden": true
234
+ },
235
+ {
236
+ "command": "unshare-make-tarball",
237
+ "help": "",
238
+ "usage": "运行pack命令",
239
+ "description": "",
240
+ "args": {
241
+ "--output": {
242
+ "flag": false,
243
+ "description": "输出文件路径"
244
+ },
245
+ "--project": {
246
+ "flag": false,
247
+ "description": "要打包的项目名称"
248
+ }
249
+ },
250
+ "commonArgs": {},
251
+ "positional": false,
252
+ "isHidden": true
220
253
  }
221
254
  ];
222
255
  export const cli_imports = {
@@ -231,5 +264,6 @@ export const cli_imports = {
231
264
  "monorepo-upgrade": "./commands/monorepo-upgrade.js",
232
265
  "run-if-version-mismatch": "./commands/run-if-version-mismatch.js",
233
266
  "sync-my-readme": "./commands/sync-my-readme.js",
234
- "test": "./commands/test.js"
267
+ "test": "./commands/test.js",
268
+ "unshare-make-tarball": "./commands/unshare-make-tarball.js"
235
269
  } as const;
@@ -1,5 +1,5 @@
1
- import { sleep, type IPackageJson } from '@idlebox/common';
2
1
  import { logger } from '@idlebox/cli';
2
+ import { sleep, type IPackageJson } from '@idlebox/common';
3
3
  import { get as cacheGet, rm as cacheRm } from 'cacache';
4
4
  import { rm } from 'node:fs/promises';
5
5
  import { createRequire } from 'node:module';
@@ -38,19 +38,23 @@ export interface IRegistryMetadata {
38
38
  }
39
39
 
40
40
  export class NpmCacheHandler {
41
+ private readonly cache_path;
42
+
41
43
  constructor(
42
44
  private readonly pm: IPackageManager,
43
45
  private readonly registry: string,
44
46
  public readonly path: string,
45
- ) {}
47
+ ) {
48
+ this.cache_path = resolve(path, '_cacache');
49
+ }
46
50
 
47
51
  deleteMetadata(name: string) {
48
- return deleteNpmCache(this.path, name, this.registry);
52
+ return deleteNpmCache(this.cache_path, name, this.registry);
49
53
  }
50
54
 
51
55
  async fetchMetadata(name: string, cacheMode = CacheMode.Normal) {
52
56
  const registry = await this.pm.getNpmRegistry();
53
- return fetchNpmWithCache(this.path, name, registry, { mode: cacheMode });
57
+ return fetchNpmWithCache(this.cache_path, name, registry, { mode: cacheMode });
54
58
  }
55
59
 
56
60
  async fetchVersion(name: string, distTag = 'latest', cacheMode = CacheMode.Normal) {
@@ -68,7 +72,7 @@ export class NpmCacheHandler {
68
72
 
69
73
  private getTarballFile(name: string, tag: string) {
70
74
  const es = escapePackageNameToFilename(name);
71
- return resolve(this.path, `../package-tools/${es}-${tag}.tgz`);
75
+ return resolve(this.path, `package-tools/${es}-${tag}.tgz`);
72
76
  }
73
77
 
74
78
  public async downloadTarball(name: string, distTag: string) {
@@ -190,8 +194,9 @@ async function deleteNpmCache(path: string, name: string, registry?: string) {
190
194
  const tc = i > 0 ? '├' : '└';
191
195
 
192
196
  const info = await cacheGet.info(path, cid);
193
- // console.log(info);
197
+ logger.verbose`cache info: ${info}`;
194
198
  await cacheRm.content(path, cid);
199
+ await cacheRm.entry(path, cid);
195
200
  // @types/cacache 最后一个参数丢失
196
201
  await (cacheRm.entry as any)(path, cid, { removeFully: true });
197
202
  if (info) {
@@ -9,13 +9,12 @@ export class DieError extends Error {
9
9
 
10
10
  /** @deprecated */
11
11
  export const isQuiet = app.silent;
12
- export const isJsonOutput = argv.flag('--json') > 0;
13
12
 
14
13
  /** @deprecated */
15
14
  export const isHelp = app.showHelp;
16
15
 
17
- export const distTagInput = argv.single('--dist-tag') || 'latest';
18
- export const registryInput = argv.single('--registry') || 'detect';
16
+ export const distTagInput = argv.single(['--dist-tag']) || 'latest';
17
+ export const registryInput = argv.single(['--registry']) || 'detect';
19
18
 
20
19
  /** @deprecated */
21
20
  export const isDebugMode = app.debug;
@@ -1,10 +1,10 @@
1
- import { ensureLinkTarget } from '@idlebox/ensure-symlink';
1
+ import type { WorkspaceBase } from '@build-script/monorepo-lib';
2
2
  import { logger } from '@idlebox/cli';
3
+ import { ensureLinkTarget } from '@idlebox/ensure-symlink';
3
4
  import { execLazyError, exists, writeFileIfChange } from '@idlebox/node';
4
5
  import { execa } from 'execa';
5
6
  import { dirname, resolve } from 'node:path';
6
7
  import { split as splitCmd } from 'split-cmd';
7
- import type { WorkspaceBase } from '@build-script/monorepo-lib';
8
8
  import { NpmCacheHandler } from '../cache/native.npm.js';
9
9
  import { registryInput } from '../functions/cli.js';
10
10
  import { TempWorkingFolder } from '../temp-work-folder.js';
@@ -54,7 +54,7 @@ export abstract class PackageManager {
54
54
  logger.fatal`publishConfig.packCommand必须是字符串或字符串数组, 但实际是: ${typeof pkg.publishConfig['packCommand']}`;
55
55
  }
56
56
 
57
- logger.debug`使用自定义打包命令: ${cmds[0]}...`;
57
+ logger.debug`使用自定义打包命令: ${Array.from(cmds)}`;
58
58
 
59
59
  const [cmd, ...args] = cmds;
60
60
  await execLazyError(cmd, [...args, '--out', saveAs], {
@@ -73,7 +73,12 @@ export abstract class PackageManager {
73
73
  }
74
74
 
75
75
  async getScope() {
76
- const pkg = await this.loadPackageJson();
76
+ let pkg;
77
+ try {
78
+ pkg = await this.loadPackageJson();
79
+ } catch {
80
+ return undefined;
81
+ }
77
82
  if (pkg.name?.startsWith('@')) {
78
83
  const name = pkg.name.split('/')[0];
79
84
  return name;
@@ -174,7 +179,7 @@ export abstract class PackageManager {
174
179
  const path = await this.getConfig('cache');
175
180
  if (!path) throw new Error('npm config get cache返回为空');
176
181
 
177
- this._cache_handler = new NpmCacheHandler(this, registry, resolve(path, '_cacache'));
182
+ this._cache_handler = new NpmCacheHandler(this, registry, path);
178
183
  }
179
184
  return this._cache_handler;
180
185
  }
@@ -33,7 +33,7 @@ export async function makePackageJsonOrderConsistence(root: string) {
33
33
  }
34
34
 
35
35
  const pkgCache: Record<string, IPackageJson> = {};
36
- export async function cachedPackageJson(path: string) {
36
+ export async function cachedPackageJson(path: string):Promise<IPackageJson> {
37
37
  const exists = pkgCache[path];
38
38
  if (exists) {
39
39
  return exists;
@@ -12,13 +12,14 @@ interface IResult {
12
12
  changedFiles: string[];
13
13
  hasChange: boolean;
14
14
  remoteVersion?: string;
15
+ packageJsonDiff?: string;
15
16
  }
16
17
 
17
18
  interface IDetectOptions {
18
19
  forcePrivate?: boolean;
19
20
  }
20
21
 
21
- export async function executeChangeDetect(pm: IPackageManager, options: IDetectOptions): Promise<IResult> {
22
+ export async function executeChangeDetect(pm: IPackageManager, options: IDetectOptions = {}): Promise<IResult> {
22
23
  const packageJson = await pm.loadPackageJson();
23
24
  logger.debug('修改检测 | 包名: %s', packageJson.name);
24
25
  if (!packageJson.name) {
@@ -72,12 +73,11 @@ export async function executeChangeDetect(pm: IPackageManager, options: IDetectO
72
73
  const changedFiles = await gitrepo.commitChanges();
73
74
  logger.verbose` changed files: list<${changedFiles}>`;
74
75
 
75
- if (logger.debug.isEnabled) {
76
- if (changedFiles.includes('package.json')) {
77
- const diff = await gitrepo.fileDiff('package.json');
78
- logger.debug(` - package.json 文件的修改:\n${diff}`);
79
- }
76
+ let packageJsonDiff = '';
77
+ if (changedFiles.includes('package.json')) {
78
+ packageJsonDiff = await gitrepo.fileDiff('package.json');
79
+ logger.debug(` - package.json 文件的修改:\n${packageJsonDiff}`);
80
80
  }
81
81
 
82
- return { changedFiles, hasChange: changedFiles.length > 0, remoteVersion: remotePackage.version };
82
+ return { changedFiles, hasChange: changedFiles.length > 0, remoteVersion: remotePackage.version, packageJsonDiff };
83
83
  }
@@ -1,5 +1,5 @@
1
- import { sleep } from '@idlebox/common';
2
1
  import { logger } from '@idlebox/cli';
2
+ import { sleep } from '@idlebox/common';
3
3
  import { exists, streamPromise } from '@idlebox/node';
4
4
  import { createWriteStream } from 'node:fs';
5
5
  import { mkdir, readFile, rename, writeFile } from 'node:fs/promises';
@@ -18,7 +18,7 @@ export async function downloadFileCached(url: string, file: string) {
18
18
  const metadata = `${file}.meta.json`;
19
19
  logger.debug`下载文件:\n 地址: long<${url}>\n 保存到: long<${file}>`;
20
20
  let meta: IMetaInfo | undefined;
21
- if (await exists(metadata)) {
21
+ if ((await exists(metadata)) && (await exists(file))) {
22
22
  try {
23
23
  meta = JSON.parse(await readFile(metadata, 'utf-8'));
24
24
  } catch {}
@@ -12,7 +12,7 @@
12
12
  *
13
13
  ******************************************************************************/
14
14
 
15
- export const self_package_version = "0.0.7";
15
+ export const self_package_version = "0.0.9";
16
16
  export const self_package_name = "@build-script/package-tools";
17
17
  export const self_package_repository = "undefined";
18
18
 
package/src/main.ts CHANGED
@@ -1,14 +1,23 @@
1
1
  import { makeApplication, type ArgDefineMap } from '@idlebox/cli';
2
+ import { setExitCodeIfNot } from '@idlebox/node';
3
+ import { basename } from 'node:path';
4
+ import pkgJson from '../package.json' with { type: 'json' };
2
5
  import { cli_commands, cli_imports } from './commands.generated.js';
3
6
 
4
7
  export const common_args: ArgDefineMap = {
5
8
  '--registry': { flag: false, description: 'npm服务器,默认从.npmrc读取(必须有schema://)' },
6
9
  '--dist-tag': { flag: false, description: '需要从服务器读取时使用的tag,默认为"latest"' },
7
10
  '--package': { flag: false, description: '实际操作前,更改当前目录(此文件夹应包含package.json)' },
8
- '--json': { flag: true, description: '输出json格式(部分命令支持)' },
9
11
  };
10
12
 
11
- await makeApplication().withCommon(common_args).static(cli_imports, cli_commands);
13
+ setExitCodeIfNot(0);
14
+ await makeApplication({
15
+ name: basename(pkgJson.name),
16
+ description: pkgJson.description,
17
+ logPrefix: process.env.LOGGER_PREFIX || '',
18
+ })
19
+ .withCommon(common_args)
20
+ .static(cli_imports, cli_commands);
12
21
 
13
22
  // await makeApplication()
14
23
  // .withCommon(common_args)
@@ -1,5 +0,0 @@
1
- export declare let isApplicationShuttingDown: boolean;
2
- export declare function shutdown(code: number): void;
3
- export declare let shutdownExtraErase: number;
4
- export declare function registerShutdownHandlers(): void;
5
- //# sourceMappingURL=global-lifecycle.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"global-lifecycle.d.ts","sourceRoot":"","sources":["../../../src/common/functions/global-lifecycle.ts"],"names":[],"mappings":"AAEA,eAAO,IAAI,yBAAyB,SAAQ,CAAC;AAE7C,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,QASpC;AAED,eAAO,IAAI,kBAAkB,QAAI,CAAC;AAElC,wBAAgB,wBAAwB,SAsBvC"}
@@ -1,34 +0,0 @@
1
- import { ensureDisposeGlobal } from '@idlebox/common';
2
- export let isApplicationShuttingDown = false;
3
- export function shutdown(code) {
4
- if (isApplicationShuttingDown) {
5
- process.exitCode = code || process.exitCode;
6
- return;
7
- }
8
- isApplicationShuttingDown = true;
9
- ensureDisposeGlobal().finally(() => {
10
- process.exit(code || process.exitCode);
11
- });
12
- }
13
- export let shutdownExtraErase = 0;
14
- export function registerShutdownHandlers() {
15
- process.on('unhandledRejection', (reason, promise) => {
16
- console.error('got unhandledRejection: %s', reason);
17
- console.error(promise);
18
- shutdown(1);
19
- });
20
- process.on('SIGINT', () => {
21
- console.error('\ngot SIGINT');
22
- shutdownExtraErase += 2;
23
- shutdown(0);
24
- });
25
- process.on('SIGTERM', () => {
26
- console.error('\ngot SIGTERM');
27
- shutdownExtraErase += 2;
28
- shutdown(0);
29
- });
30
- process.on('beforeExit', (code) => {
31
- shutdown(code);
32
- });
33
- }
34
- //# sourceMappingURL=global-lifecycle.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"global-lifecycle.js","sourceRoot":"","sources":["../../../src/common/functions/global-lifecycle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtD,MAAM,CAAC,IAAI,yBAAyB,GAAG,KAAK,CAAC;AAE7C,MAAM,UAAU,QAAQ,CAAC,IAAY;IACpC,IAAI,yBAAyB,EAAE,CAAC;QAC/B,OAAO,CAAC,QAAQ,GAAG,IAAI,IAAI,OAAO,CAAC,QAAQ,CAAC;QAC5C,OAAO;IACR,CAAC;IACD,yBAAyB,GAAG,IAAI,CAAC;IACjC,mBAAmB,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE;QAClC,OAAO,CAAC,IAAI,CAAC,IAAI,IAAI,OAAO,CAAC,QAAQ,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,IAAI,kBAAkB,GAAG,CAAC,CAAC;AAElC,MAAM,UAAU,wBAAwB;IACvC,OAAO,CAAC,EAAE,CAAC,oBAAoB,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE;QACpD,OAAO,CAAC,KAAK,CAAC,4BAA4B,EAAE,MAAM,CAAC,CAAC;QACpD,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACvB,QAAQ,CAAC,CAAC,CAAC,CAAC;IACb,CAAC,CAAC,CAAC;IAEH,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;QACzB,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;QAC9B,kBAAkB,IAAI,CAAC,CAAC;QACxB,QAAQ,CAAC,CAAC,CAAC,CAAC;IACb,CAAC,CAAC,CAAC;IAEH,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE;QAC1B,OAAO,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;QAC/B,kBAAkB,IAAI,CAAC,CAAC;QACxB,QAAQ,CAAC,CAAC,CAAC,CAAC;IACb,CAAC,CAAC,CAAC;IAEH,OAAO,CAAC,EAAE,CAAC,YAAY,EAAE,CAAC,IAAI,EAAE,EAAE;QACjC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAChB,CAAC,CAAC,CAAC;AACJ,CAAC"}
@@ -1,40 +0,0 @@
1
- import { ensureDisposeGlobal } from '@idlebox/common';
2
-
3
- export let isApplicationShuttingDown = false;
4
-
5
- export function shutdown(code: number) {
6
- if (isApplicationShuttingDown) {
7
- process.exitCode = code || process.exitCode;
8
- return;
9
- }
10
- isApplicationShuttingDown = true;
11
- ensureDisposeGlobal().finally(() => {
12
- process.exit(code || process.exitCode);
13
- });
14
- }
15
-
16
- export let shutdownExtraErase = 0;
17
-
18
- export function registerShutdownHandlers() {
19
- process.on('unhandledRejection', (reason, promise) => {
20
- console.error('got unhandledRejection: %s', reason);
21
- console.error(promise);
22
- shutdown(1);
23
- });
24
-
25
- process.on('SIGINT', () => {
26
- console.error('\ngot SIGINT');
27
- shutdownExtraErase += 2;
28
- shutdown(0);
29
- });
30
-
31
- process.on('SIGTERM', () => {
32
- console.error('\ngot SIGTERM');
33
- shutdownExtraErase += 2;
34
- shutdown(0);
35
- });
36
-
37
- process.on('beforeExit', (code) => {
38
- shutdown(code);
39
- });
40
- }