@botpress/cli 2.0.1 → 2.0.3
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.
- package/.turbo/turbo-build.log +11 -11
- package/dist/api/bot-body.js +4 -0
- package/dist/api/bot-body.js.map +1 -1
- package/dist/api/client.js +4 -0
- package/dist/api/client.js.map +1 -1
- package/dist/api/find-previous-version.js +4 -0
- package/dist/api/find-previous-version.js.map +1 -1
- package/dist/api/find-previous-version.test.js +4 -0
- package/dist/api/find-previous-version.test.js.map +1 -1
- package/dist/api/integration-body.js +4 -0
- package/dist/api/integration-body.js.map +1 -1
- package/dist/api/interface-body.js +4 -0
- package/dist/api/interface-body.js.map +1 -1
- package/dist/api/paging.js.map +1 -1
- package/dist/api/plugin-body.js +5 -0
- package/dist/api/plugin-body.js.map +1 -1
- package/dist/code-generation/bot-implementation/bot-implementation.js +5 -0
- package/dist/code-generation/bot-implementation/bot-implementation.js.map +1 -1
- package/dist/code-generation/bot-implementation/bot-plugins/index.js +4 -0
- package/dist/code-generation/bot-implementation/bot-plugins/index.js.map +1 -1
- package/dist/code-generation/bot-implementation/bot-plugins/plugin-module.js +4 -0
- package/dist/code-generation/bot-implementation/bot-plugins/plugin-module.js.map +1 -1
- package/dist/code-generation/bot-implementation/bot-typings/actions-module.js +4 -0
- package/dist/code-generation/bot-implementation/bot-typings/actions-module.js.map +1 -1
- package/dist/code-generation/bot-implementation/bot-typings/events-module.js +4 -0
- package/dist/code-generation/bot-implementation/bot-typings/events-module.js.map +1 -1
- package/dist/code-generation/bot-implementation/bot-typings/index.js +4 -0
- package/dist/code-generation/bot-implementation/bot-typings/index.js.map +1 -1
- package/dist/code-generation/bot-implementation/bot-typings/states-module.js +4 -0
- package/dist/code-generation/bot-implementation/bot-typings/states-module.js.map +1 -1
- package/dist/code-generation/bot-implementation/index.js +5 -0
- package/dist/code-generation/bot-implementation/index.js.map +1 -1
- package/dist/code-generation/generators.js +5 -0
- package/dist/code-generation/generators.js.map +1 -1
- package/dist/code-generation/integration-implementation/index.js +4 -0
- package/dist/code-generation/integration-implementation/index.js.map +1 -1
- package/dist/code-generation/integration-implementation/integration-implementation.js +4 -0
- package/dist/code-generation/integration-implementation/integration-implementation.js.map +1 -1
- package/dist/code-generation/integration-implementation/integration-secret.js +4 -0
- package/dist/code-generation/integration-implementation/integration-secret.js.map +1 -1
- package/dist/code-generation/integration-implementation/integration-typings/actions-module.js +4 -0
- package/dist/code-generation/integration-implementation/integration-typings/actions-module.js.map +1 -1
- package/dist/code-generation/integration-implementation/integration-typings/channels-module.js +4 -0
- package/dist/code-generation/integration-implementation/integration-typings/channels-module.js.map +1 -1
- package/dist/code-generation/integration-implementation/integration-typings/configuration-module.js +4 -0
- package/dist/code-generation/integration-implementation/integration-typings/configuration-module.js.map +1 -1
- package/dist/code-generation/integration-implementation/integration-typings/configurations-module.js +4 -0
- package/dist/code-generation/integration-implementation/integration-typings/configurations-module.js.map +1 -1
- package/dist/code-generation/integration-implementation/integration-typings/entities-module.js +4 -0
- package/dist/code-generation/integration-implementation/integration-typings/entities-module.js.map +1 -1
- package/dist/code-generation/integration-implementation/integration-typings/events-module.js +4 -0
- package/dist/code-generation/integration-implementation/integration-typings/events-module.js.map +1 -1
- package/dist/code-generation/integration-implementation/integration-typings/states-module.js +4 -0
- package/dist/code-generation/integration-implementation/integration-typings/states-module.js.map +1 -1
- package/dist/code-generation/integration-package/index.js +4 -0
- package/dist/code-generation/integration-package/index.js.map +1 -1
- package/dist/code-generation/integration-package/integration-package-definition/actions-module.js +4 -0
- package/dist/code-generation/integration-package/integration-package-definition/actions-module.js.map +1 -1
- package/dist/code-generation/integration-package/integration-package-definition/channels-module.js +4 -0
- package/dist/code-generation/integration-package/integration-package-definition/channels-module.js.map +1 -1
- package/dist/code-generation/integration-package/integration-package-definition/configuration-module.js +5 -0
- package/dist/code-generation/integration-package/integration-package-definition/configuration-module.js.map +1 -1
- package/dist/code-generation/integration-package/integration-package-definition/configurations-module.js +4 -0
- package/dist/code-generation/integration-package/integration-package-definition/configurations-module.js.map +1 -1
- package/dist/code-generation/integration-package/integration-package-definition/entities-module.js +4 -0
- package/dist/code-generation/integration-package/integration-package-definition/entities-module.js.map +1 -1
- package/dist/code-generation/integration-package/integration-package-definition/events-module.js +4 -0
- package/dist/code-generation/integration-package/integration-package-definition/events-module.js.map +1 -1
- package/dist/code-generation/integration-package/integration-package-definition/index.js +4 -0
- package/dist/code-generation/integration-package/integration-package-definition/index.js.map +1 -1
- package/dist/code-generation/integration-package/integration-package-definition/states-module.js +4 -0
- package/dist/code-generation/integration-package/integration-package-definition/states-module.js.map +1 -1
- package/dist/code-generation/interface-implementation/integration-typings/actions-module.js +4 -0
- package/dist/code-generation/interface-implementation/integration-typings/actions-module.js.map +1 -1
- package/dist/code-generation/interface-implementation/integration-typings/channels-module.js +4 -0
- package/dist/code-generation/interface-implementation/integration-typings/channels-module.js.map +1 -1
- package/dist/code-generation/interface-implementation/integration-typings/entities-module.js +4 -0
- package/dist/code-generation/interface-implementation/integration-typings/entities-module.js.map +1 -1
- package/dist/code-generation/interface-implementation/integration-typings/events-module.js +4 -0
- package/dist/code-generation/interface-implementation/integration-typings/events-module.js.map +1 -1
- package/dist/code-generation/interface-implementation/integration-typings/index.js +4 -0
- package/dist/code-generation/interface-implementation/integration-typings/index.js.map +1 -1
- package/dist/code-generation/interface-package/index.js +4 -0
- package/dist/code-generation/interface-package/index.js.map +1 -1
- package/dist/code-generation/interface-package/interface-package-definition/actions-module.js +4 -0
- package/dist/code-generation/interface-package/interface-package-definition/actions-module.js.map +1 -1
- package/dist/code-generation/interface-package/interface-package-definition/channels-module.js +4 -0
- package/dist/code-generation/interface-package/interface-package-definition/channels-module.js.map +1 -1
- package/dist/code-generation/interface-package/interface-package-definition/entities-module.js +4 -0
- package/dist/code-generation/interface-package/interface-package-definition/entities-module.js.map +1 -1
- package/dist/code-generation/interface-package/interface-package-definition/events-module.js +4 -0
- package/dist/code-generation/interface-package/interface-package-definition/events-module.js.map +1 -1
- package/dist/code-generation/interface-package/interface-package-definition/index.js +4 -0
- package/dist/code-generation/interface-package/interface-package-definition/index.js.map +1 -1
- package/dist/code-generation/module.js +7 -0
- package/dist/code-generation/module.js.map +1 -1
- package/dist/code-generation/plugin-implementation/index.js +4 -0
- package/dist/code-generation/plugin-implementation/index.js.map +1 -1
- package/dist/code-generation/plugin-implementation/plugin-implementation.js +4 -0
- package/dist/code-generation/plugin-implementation/plugin-implementation.js.map +1 -1
- package/dist/code-generation/plugin-implementation/plugin-typings/actions-module.js +4 -0
- package/dist/code-generation/plugin-implementation/plugin-typings/actions-module.js.map +1 -1
- package/dist/code-generation/plugin-implementation/plugin-typings/configuration-module.js +4 -0
- package/dist/code-generation/plugin-implementation/plugin-typings/configuration-module.js.map +1 -1
- package/dist/code-generation/plugin-implementation/plugin-typings/events-module.js +4 -0
- package/dist/code-generation/plugin-implementation/plugin-typings/events-module.js.map +1 -1
- package/dist/code-generation/plugin-implementation/plugin-typings/index.js +4 -0
- package/dist/code-generation/plugin-implementation/plugin-typings/index.js.map +1 -1
- package/dist/code-generation/plugin-implementation/plugin-typings/states-module.js +4 -0
- package/dist/code-generation/plugin-implementation/plugin-typings/states-module.js.map +1 -1
- package/dist/code-generation/plugin-package/index.js +5 -0
- package/dist/code-generation/plugin-package/index.js.map +1 -1
- package/dist/code-generation/plugin-package/plugin-package-definition/actions-module.js +4 -0
- package/dist/code-generation/plugin-package/plugin-package-definition/actions-module.js.map +1 -1
- package/dist/code-generation/plugin-package/plugin-package-definition/configuration-module.js +4 -0
- package/dist/code-generation/plugin-package/plugin-package-definition/configuration-module.js.map +1 -1
- package/dist/code-generation/plugin-package/plugin-package-definition/events-module.js +4 -0
- package/dist/code-generation/plugin-package/plugin-package-definition/events-module.js.map +1 -1
- package/dist/code-generation/plugin-package/plugin-package-definition/index.js +4 -0
- package/dist/code-generation/plugin-package/plugin-package-definition/index.js.map +1 -1
- package/dist/code-generation/plugin-package/plugin-package-definition/states-module.js +4 -0
- package/dist/code-generation/plugin-package/plugin-package-definition/states-module.js.map +1 -1
- package/dist/code-generation/strings.js +4 -0
- package/dist/code-generation/strings.js.map +1 -1
- package/dist/command-definitions.js +4 -0
- package/dist/command-definitions.js.map +1 -1
- package/dist/command-implementations/add-command.js +67 -15
- package/dist/command-implementations/add-command.js.map +2 -2
- package/dist/command-implementations/base-command.js +4 -0
- package/dist/command-implementations/base-command.js.map +1 -1
- package/dist/command-implementations/bot-commands.js +4 -0
- package/dist/command-implementations/bot-commands.js.map +1 -1
- package/dist/command-implementations/bundle-command.js +4 -0
- package/dist/command-implementations/bundle-command.js.map +1 -1
- package/dist/command-implementations/deploy-command.js +4 -0
- package/dist/command-implementations/deploy-command.js.map +1 -1
- package/dist/command-implementations/dev-command.js +4 -0
- package/dist/command-implementations/dev-command.js.map +1 -1
- package/dist/command-implementations/gen-command.js +6 -1
- package/dist/command-implementations/gen-command.js.map +2 -2
- package/dist/command-implementations/global-command.js +4 -0
- package/dist/command-implementations/global-command.js.map +1 -1
- package/dist/command-implementations/index.js +4 -0
- package/dist/command-implementations/index.js.map +1 -1
- package/dist/command-implementations/init-command.js +4 -0
- package/dist/command-implementations/init-command.js.map +1 -1
- package/dist/command-implementations/integration-commands.js +4 -0
- package/dist/command-implementations/integration-commands.js.map +1 -1
- package/dist/command-implementations/interface-commands.js +4 -0
- package/dist/command-implementations/interface-commands.js.map +1 -1
- package/dist/command-implementations/lint-command.js +27 -0
- package/dist/command-implementations/lint-command.js.map +2 -2
- package/dist/command-implementations/login-command.js +4 -0
- package/dist/command-implementations/login-command.js.map +1 -1
- package/dist/command-implementations/plugin-commands.js +4 -0
- package/dist/command-implementations/plugin-commands.js.map +1 -1
- package/dist/command-implementations/project-command.js +4 -0
- package/dist/command-implementations/project-command.js.map +1 -1
- package/dist/command-implementations/read-command.js +4 -0
- package/dist/command-implementations/read-command.js.map +1 -1
- package/dist/command-implementations/serve-command.js +4 -0
- package/dist/command-implementations/serve-command.js.map +1 -1
- package/dist/command-tree.js.map +1 -1
- package/dist/config.js +7 -1
- package/dist/config.js.map +2 -2
- package/dist/consts.js +4 -0
- package/dist/consts.js.map +1 -1
- package/dist/errors.js +4 -0
- package/dist/errors.js.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/init.js +4 -0
- package/dist/init.js.map +1 -1
- package/dist/linter/base-linter.js.map +1 -1
- package/dist/linter/base-linter.test.js.map +1 -1
- package/dist/linter/ruleset-tests/bot.ruleset.test.js.map +1 -1
- package/dist/linter/ruleset-tests/common.js.map +1 -1
- package/dist/linter/ruleset-tests/integration.ruleset.test.js.map +1 -1
- package/dist/linter/ruleset-tests/interface.ruleset.test.js.map +1 -1
- package/dist/linter/rulesets/bot.ruleset.js.map +1 -1
- package/dist/linter/rulesets/integration.ruleset.js.map +1 -1
- package/dist/linter/rulesets/interface.ruleset.js.map +1 -1
- package/dist/logger/base-logger.js +4 -0
- package/dist/logger/base-logger.js.map +1 -1
- package/dist/logger/index.js +1 -0
- package/dist/logger/index.js.map +1 -1
- package/dist/package-ref.js +33 -0
- package/dist/package-ref.js.map +2 -2
- package/dist/package-ref.test.js +22 -0
- package/dist/package-ref.test.js.map +2 -2
- package/dist/register-yargs.js +4 -0
- package/dist/register-yargs.js.map +1 -1
- package/dist/root.js +4 -0
- package/dist/root.js.map +1 -1
- package/dist/sdk/resolve-integration-interfaces.js +5 -0
- package/dist/sdk/resolve-integration-interfaces.js.map +1 -1
- package/dist/sdk/validate-bot.js +4 -0
- package/dist/sdk/validate-bot.js.map +1 -1
- package/dist/sdk/validate-integration.js +4 -0
- package/dist/sdk/validate-integration.js.map +1 -1
- package/dist/utils/cache-utils.js +4 -0
- package/dist/utils/cache-utils.js.map +1 -1
- package/dist/utils/case-utils.js +4 -0
- package/dist/utils/case-utils.js.map +1 -1
- package/dist/utils/case-utils.test.js +4 -0
- package/dist/utils/case-utils.test.js.map +1 -1
- package/dist/utils/event-emitter.js.map +1 -1
- package/dist/utils/file-watcher.js +4 -0
- package/dist/utils/file-watcher.js.map +1 -1
- package/dist/utils/id-utils.js +4 -0
- package/dist/utils/id-utils.js.map +1 -1
- package/dist/utils/index.js +4 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/object-utils.js.map +1 -1
- package/dist/utils/path-utils.js +6 -2
- package/dist/utils/path-utils.js.map +1 -1
- package/dist/utils/path-utils.test.js +4 -0
- package/dist/utils/path-utils.test.js.map +1 -1
- package/dist/utils/pkgjson-utils.js +4 -0
- package/dist/utils/pkgjson-utils.js.map +2 -2
- package/dist/utils/promise-utils.js.map +1 -1
- package/dist/utils/prompt-utils.js +4 -0
- package/dist/utils/prompt-utils.js.map +1 -1
- package/dist/utils/record-utils.js +4 -0
- package/dist/utils/record-utils.js.map +1 -1
- package/dist/utils/record-utils.test.js +4 -0
- package/dist/utils/record-utils.test.js.map +1 -1
- package/dist/utils/require-utils.js +4 -0
- package/dist/utils/require-utils.js.map +1 -1
- package/dist/utils/require-utils.test.js +4 -0
- package/dist/utils/require-utils.test.js.map +1 -1
- package/dist/utils/schema-utils.js.map +1 -1
- package/dist/utils/semver-utils.js.map +1 -1
- package/dist/utils/template-utils.js +4 -0
- package/dist/utils/template-utils.js.map +1 -1
- package/dist/utils/tunnel-utils.js +3 -0
- package/dist/utils/tunnel-utils.js.map +1 -1
- package/dist/worker/child-entrypoint.js +4 -0
- package/dist/worker/child-entrypoint.js.map +1 -1
- package/dist/worker/child-wrapper.js +5 -0
- package/dist/worker/child-wrapper.js.map +1 -1
- package/dist/worker/is-child.js.map +1 -1
- package/dist/worker/worker-state.js.map +1 -1
- package/dist/worker/worker.js +3 -0
- package/dist/worker/worker.js.map +1 -1
- package/package.json +6 -8
- package/templates/empty-bot/package.json +4 -5
- package/templates/empty-integration/package.json +4 -5
- package/templates/empty-plugin/package.json +3 -4
- package/templates/hello-world/package.json +4 -5
- package/templates/webhook-message/package.json +4 -5
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/case-utils.test.ts"],
|
|
4
4
|
"sourcesContent": ["import { test, expect } from 'vitest'\nimport * as caseUtils from './case-utils'\n\nconst pascalCase = 'HelloLittleWorld'\nconst kebabCase = 'hello-little-world'\nconst snakeCase = 'hello_little_world'\nconst screamingSnakeCase = 'HELLO_LITTLE_WORLD'\nconst camelCase = 'helloLittleWorld'\n\ntest('case utils should convert from pascal case to all other cases', () => {\n expect(caseUtils.to.kebabCase(pascalCase)).toBe(kebabCase)\n expect(caseUtils.to.snakeCase(pascalCase)).toBe(snakeCase)\n expect(caseUtils.to.screamingSnakeCase(pascalCase)).toBe(screamingSnakeCase)\n expect(caseUtils.to.camelCase(pascalCase)).toBe(camelCase)\n})\n\ntest('case utils should convert from kebab case to all other cases', () => {\n expect(caseUtils.to.pascalCase(kebabCase)).toBe(pascalCase)\n expect(caseUtils.to.snakeCase(kebabCase)).toBe(snakeCase)\n expect(caseUtils.to.screamingSnakeCase(kebabCase)).toBe(screamingSnakeCase)\n expect(caseUtils.to.camelCase(kebabCase)).toBe(camelCase)\n})\n\ntest('case utils should convert from snake case to all other cases', () => {\n expect(caseUtils.to.pascalCase(snakeCase)).toBe(pascalCase)\n expect(caseUtils.to.kebabCase(snakeCase)).toBe(kebabCase)\n expect(caseUtils.to.screamingSnakeCase(snakeCase)).toBe(screamingSnakeCase)\n expect(caseUtils.to.camelCase(snakeCase)).toBe(camelCase)\n})\n\ntest('case utils should convert from screaming snake case to all other cases', () => {\n expect(caseUtils.to.pascalCase(screamingSnakeCase)).toBe(pascalCase)\n expect(caseUtils.to.kebabCase(screamingSnakeCase)).toBe(kebabCase)\n expect(caseUtils.to.snakeCase(screamingSnakeCase)).toBe(snakeCase)\n expect(caseUtils.to.camelCase(screamingSnakeCase)).toBe(camelCase)\n})\n\ntest('case utils should convert from camel case to all other cases', () => {\n expect(caseUtils.to.pascalCase(camelCase)).toBe(pascalCase)\n expect(caseUtils.to.kebabCase(camelCase)).toBe(kebabCase)\n expect(caseUtils.to.snakeCase(camelCase)).toBe(snakeCase)\n expect(caseUtils.to.screamingSnakeCase(camelCase)).toBe(screamingSnakeCase)\n})\n\ntest('case utils should split special characters when converting', () => {\n expect(caseUtils.to.pascalCase(`${pascalCase}.2`)).toBe(`${pascalCase}2`)\n expect(caseUtils.to.kebabCase(`${kebabCase}.2`)).toBe(`${kebabCase}-2`)\n expect(caseUtils.to.snakeCase(`${snakeCase}.2`)).toBe(`${snakeCase}_2`)\n expect(caseUtils.to.screamingSnakeCase(`${screamingSnakeCase}.2`)).toBe(`${screamingSnakeCase}_2`)\n expect(caseUtils.to.camelCase(`${camelCase}.2`)).toBe(`${camelCase}2`)\n})\n\ntest('case utils should prevent special characters when checking', () => {\n expect(caseUtils.is.pascalCase(`${pascalCase}.2`)).toBe(false)\n expect(caseUtils.is.kebabCase(`${kebabCase}.2`)).toBe(false)\n expect(caseUtils.is.snakeCase(`${snakeCase}.2`)).toBe(false)\n expect(caseUtils.is.screamingSnakeCase(`${screamingSnakeCase}.2`)).toBe(false)\n expect(caseUtils.is.camelCase(`${camelCase}.2`)).toBe(false)\n})\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA,oBAA6B;AAC7B,gBAA2B;AAE3B,MAAM,aAAa;AACnB,MAAM,YAAY;AAClB,MAAM,YAAY;AAClB,MAAM,qBAAqB;AAC3B,MAAM,YAAY;AAAA,IAElB,oBAAK,iEAAiE,MAAM;AAC1E,4BAAO,UAAU,GAAG,UAAU,UAAU,CAAC,EAAE,KAAK,SAAS;AACzD,4BAAO,UAAU,GAAG,UAAU,UAAU,CAAC,EAAE,KAAK,SAAS;AACzD,4BAAO,UAAU,GAAG,mBAAmB,UAAU,CAAC,EAAE,KAAK,kBAAkB;AAC3E,4BAAO,UAAU,GAAG,UAAU,UAAU,CAAC,EAAE,KAAK,SAAS;AAC3D,CAAC;AAAA,IAED,oBAAK,gEAAgE,MAAM;AACzE,4BAAO,U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E,KAAK,GAAG,aAAa;AACxE,4BAAO,UAAU,GAAG,UAAU,GAAG,aAAa,CAAC,EAAE,KAAK,GAAG,aAAa;AACtE,4BAAO,UAAU,GAAG,UAAU,GAAG,aAAa,CAAC,EAAE,KAAK,GAAG,aAAa;AACtE,4BAAO,UAAU,GAAG,mBAAmB,GAAG,sBAAsB,CAAC,EAAE,KAAK,GAAG,sBAAsB;AACjG,4BAAO,UAAU,GAAG,UAAU,GAAG,aAAa,CAAC,EAAE,KAAK,GAAG,YAAY;AACvE,CAAC;AAAA,IAED,oBAAK,8DAA8D,MAAM;AACvE,4BAAO,UAAU,GAAG,WAAW,GAAG,cAAc,CAAC,EAAE,KAAK,KAAK;AAC7D,4BAAO,UAAU,GAAG,UAAU,GAAG,aAAa,CAAC,EAAE,KAAK,KAAK;AAC3D,4BAAO,UAAU,GAAG,UAAU,GAAG,aAAa,CAAC,EAAE,KAAK,KAAK;AAC3D,4BAAO,UAAU,GAAG,mBAAmB,GAAG,sBAAsB,CAAC,EAAE,KAAK,KAAK;AAC7E,4BAAO,UAAU,GAAG,UAAU,GAAG,aAAa,CAAC,EAAE,KAAK,KAAK;AAC7D,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/event-emitter.ts"],
|
|
4
4
|
"sourcesContent": ["export class EventEmitter<E extends object> {\n private _listeners: {\n [K in keyof E]?: ((event: E[K]) => void)[]\n } = {}\n\n public emit<K extends keyof E>(type: K, event: E[K]) {\n const listeners = this._listeners[type]\n if (!listeners) {\n return\n }\n for (const listener of listeners) {\n listener(event)\n }\n }\n\n public once<K extends keyof E>(type: K, listener: (event: E[K]) => void) {\n const wrapped = (event: E[K]) => {\n this.off(type, wrapped)\n listener(event)\n }\n this.on(type, wrapped)\n }\n\n public on<K extends keyof E>(type: K, listener: (event: E[K]) => void) {\n if (!this._listeners[type]) {\n this._listeners[type] = []\n }\n this._listeners[type]!.push(listener)\n }\n\n public off<K extends keyof E>(type: K, listener: (event: E[K]) => void) {\n const listeners = this._listeners[type]\n if (!listeners) {\n return\n }\n const index = listeners.indexOf(listener)\n if (index !== -1) {\n listeners.splice(index, 1)\n }\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,aAA+B;AAAA,EAClC,aAEJ,CAAC;AAAA,EAEE,KAAwB,MAAS,OAAa;AACnD,UAAM,YAAY,KAAK,WAAW;
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,aAA+B;AAAA,EAClC,aAEJ,CAAC;AAAA,EAEE,KAAwB,MAAS,OAAa;AACnD,UAAM,YAAY,KAAK,WAAW,IAAI;AACtC,QAAI,CAAC,WAAW;AACd;AAAA,IACF;AACA,eAAW,YAAY,WAAW;AAChC,eAAS,KAAK;AAAA,IAChB;AAAA,EACF;AAAA,EAEO,KAAwB,MAAS,UAAiC;AACvE,UAAM,UAAU,CAAC,UAAgB;AAC/B,WAAK,IAAI,MAAM,OAAO;AACtB,eAAS,KAAK;AAAA,IAChB;AACA,SAAK,GAAG,MAAM,OAAO;AAAA,EACvB;AAAA,EAEO,GAAsB,MAAS,UAAiC;AACrE,QAAI,CAAC,KAAK,WAAW,IAAI,GAAG;AAC1B,WAAK,WAAW,IAAI,IAAI,CAAC;AAAA,IAC3B;AACA,SAAK,WAAW,IAAI,EAAG,KAAK,QAAQ;AAAA,EACtC;AAAA,EAEO,IAAuB,MAAS,UAAiC;AACtE,UAAM,YAAY,KAAK,WAAW,IAAI;AACtC,QAAI,CAAC,WAAW;AACd;AAAA,IACF;AACA,UAAM,QAAQ,UAAU,QAAQ,QAAQ;AACxC,QAAI,UAAU,IAAI;AAChB,gBAAU,OAAO,OAAO,CAAC;AAAA,IAC3B;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -18,6 +18,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
20
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
25
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
26
|
mod
|
|
23
27
|
));
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/file-watcher.ts"],
|
|
4
4
|
"sourcesContent": ["import watcher from '@parcel/watcher'\nimport { EventEmitter } from './event-emitter'\n\nexport type FileChangeHandler = (events: watcher.Event[]) => Promise<void>\n\ntype EmptyObject = Record<never, never>\ntype FileWatcherEvent = {\n error: unknown\n close: EmptyObject\n}\n\n/**\n * Wraps the Parcel file watcher to ensure errors can be catched in an async/await fashion\n */\nexport class FileWatcher {\n public static async watch(dir: string, fn: FileChangeHandler, opt?: watcher.Options) {\n const eventEmitter = new EventEmitter<FileWatcherEvent>()\n const subscription = await watcher.subscribe(\n dir,\n async (err: Error | null, events: watcher.Event[]) => {\n if (err) {\n eventEmitter.emit('error', err)\n return\n }\n\n try {\n await fn(events)\n } catch (thrown) {\n eventEmitter.emit('error', thrown)\n }\n },\n opt\n )\n return new FileWatcher(subscription, eventEmitter)\n }\n\n private constructor(\n private _subscription: watcher.AsyncSubscription,\n private _errorEmitter: EventEmitter<FileWatcherEvent>\n ) {}\n\n public async close() {\n await this._subscription.unsubscribe()\n this._errorEmitter.emit('close', {})\n }\n\n public wait = () =>\n new Promise((resolve, reject) => {\n this._errorEmitter.once('error', reject)\n this._errorEmitter.once('close', resolve)\n })\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAoB;AACpB,2BAA6B;AAatB,MAAM,YAAY;AAAA,EAsBf,YACE,eACA,eACR;AAFQ;AACA;AAAA,EACP;AAAA,EAxBH,aAAoB,MAAM,KAAa,IAAuB,KAAuB;AACnF,UAAM,eAAe,IAAI,kCAA+B;AACxD,UAAM,eAAe,MAAM,eAAAA,QAAQ;AAAA,MACjC;AAAA,MACA,OAAO,KAAmB,WAA4B;AACpD,YAAI,KAAK;AACP,uBAAa,KAAK,SAAS,GAAG;AAC9B;AAAA,QACF;AAEA,YAAI;AACF,gBAAM,GAAG,MAAM;AAAA,QACjB,SAAS,QAAP;AACA,uBAAa,KAAK,SAAS,MAAM;AAAA,QACnC;AAAA,MACF;AAAA,MACA;AAAA,IACF;AACA,WAAO,IAAI,YAAY,cAAc,YAAY;AAAA,EACnD;AAAA,EAOA,MAAa,QAAQ;AACnB,UAAM,KAAK,cAAc,YAAY;AACrC,SAAK,cAAc,KAAK,SAAS,CAAC,CAAC;AAAA,EACrC;AAAA,EAEO,OAAO,MACZ,IAAI,QAAQ,CAAC,SAAS,WAAW;AAC/B,SAAK,cAAc,KAAK,SAAS,MAAM;AACvC,SAAK,cAAc,KAAK,SAAS,OAAO;AAAA,EAC1C,CAAC;AACL;",
|
|
6
6
|
"names": ["watcher"]
|
|
7
7
|
}
|
package/dist/utils/id-utils.js
CHANGED
|
@@ -18,6 +18,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
20
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
25
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
26
|
mod
|
|
23
27
|
));
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/id-utils.ts"],
|
|
4
4
|
"sourcesContent": ["import { prefixToObjectMap } from '@bpinternal/const'\nimport * as uuid from 'uuid'\n\nconst ULID_LENGTH = 26 // Reference: https://github.com/ulid/spec#canonical-string-representation\n\nexport function isValidID(id: string) {\n // Note: UUIDs were used first and then prefixed ULIDs were introduced.\n return isPrefixedULID(id) || uuid.validate(id)\n}\n\nexport function isPrefixedULID(id: string) {\n const [prefix, identifier] = id.split('_')\n\n if (!(prefix && identifier)) {\n return false\n }\n\n if (!Object.keys(prefixToObjectMap).includes(prefix)) {\n return false\n }\n\n if (identifier.length < ULID_LENGTH) {\n return false\n }\n\n return true\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkC;AAClC,WAAsB;AAEtB,MAAM,cAAc;AAEb,SAAS,UAAU,IAAY;AAEpC,SAAO,eAAe,EAAE,KAAK,KAAK,SAAS,EAAE;AAC/C;AAEO,SAAS,eAAe,IAAY;AACzC,QAAM,CAAC,QAAQ,UAAU,IAAI,GAAG,MAAM,GAAG;AAEzC,MAAI,EAAE,UAAU,aAAa;AAC3B,WAAO;AAAA,EACT;AAEA,MAAI,CAAC,OAAO,KAAK,8BAAiB,EAAE,SAAS,MAAM,GAAG;AACpD,WAAO;AAAA,EACT;AAEA,MAAI,WAAW,SAAS,aAAa;AACnC,WAAO;AAAA,EACT;AAEA,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/utils/index.js
CHANGED
|
@@ -18,6 +18,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
20
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
25
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
26
|
mod
|
|
23
27
|
));
|
package/dist/utils/index.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/index.ts"],
|
|
4
4
|
"sourcesContent": ["export * as cache from './cache-utils'\nexport * as casing from './case-utils'\nexport * as emitter from './event-emitter'\nexport * as esbuild from './esbuild-utils'\nexport * as filewatcher from './file-watcher'\nexport * as guards from './guard-utils'\nexport * as id from './id-utils'\nexport * as object from './object-utils'\nexport * as path from './path-utils'\nexport * as pkgJson from './pkgjson-utils'\nexport * as promises from './promise-utils'\nexport * as prompt from './prompt-utils'\nexport * as records from './record-utils'\nexport * as require from './require-utils'\nexport * as schema from './schema-utils'\nexport * as semver from './semver-utils'\nexport * as string from './string-utils'\nexport * as template from './template-utils'\nexport * as tunnel from './tunnel-utils'\nexport * as types from './type-utils'\nexport * as url from './url-utils'\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAAA;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,YAAuB;AACvB,aAAwB;AACxB,cAAyB;AACzB,cAAyB;AACzB,kBAA6B;AAC7B,aAAwB;AACxB,SAAoB;AACpB,aAAwB;AACxB,WAAsB;AACtB,cAAyB;AACzB,eAA0B;AAC1B,aAAwB;AACxB,cAAyB;AACzB,IAAAA,WAAyB;AACzB,aAAwB;AACxB,aAAwB;AACxB,aAAwB;AACxB,eAA0B;AAC1B,aAAwB;AACxB,YAAuB;AACvB,UAAqB;",
|
|
6
6
|
"names": ["require"]
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/object-utils.ts"],
|
|
4
4
|
"sourcesContent": ["export const omit = <O extends object, K extends keyof O>(obj: O, property: K): Omit<O, K> => {\n const { [property]: _, ...rest } = obj\n return rest\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,OAAO,CAAsC,KAAQ,aAA4B;AAC5F,QAAM,GAAG,
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,OAAO,CAAsC,KAAQ,aAA4B;AAC5F,QAAM,EAAE,CAAC,QAAQ,GAAG,GAAG,GAAG,KAAK,IAAI;AACnC,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/utils/path-utils.js
CHANGED
|
@@ -18,6 +18,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
20
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
25
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
26
|
mod
|
|
23
27
|
));
|
|
@@ -42,13 +46,13 @@ var import_os = __toESM(require("os"));
|
|
|
42
46
|
var import_path = __toESM(require("path"));
|
|
43
47
|
var posix;
|
|
44
48
|
((posix2) => {
|
|
45
|
-
posix2.isPath = (path) => posix2.isAbsolutePath(path) || posix2.isRelativePath(path);
|
|
49
|
+
posix2.isPath = (path) => (0, posix2.isAbsolutePath)(path) || (0, posix2.isRelativePath)(path);
|
|
46
50
|
posix2.isRelativePath = (path) => path.startsWith("./") || path.startsWith("../");
|
|
47
51
|
posix2.isAbsolutePath = (path) => import_path.default.posix.isAbsolute(path);
|
|
48
52
|
})(posix || (posix = {}));
|
|
49
53
|
var win32;
|
|
50
54
|
((win322) => {
|
|
51
|
-
win322.isPath = (path) => win322.isAbsolutePath(path) || win322.isRelativePath(path);
|
|
55
|
+
win322.isPath = (path) => (0, win322.isAbsolutePath)(path) || (0, win322.isRelativePath)(path);
|
|
52
56
|
win322.isRelativePath = (path) => path.startsWith(".\\") || path.startsWith("..\\");
|
|
53
57
|
win322.isAbsolutePath = (path) => /^[a-zA-Z]:\\/.test(path);
|
|
54
58
|
win322.escapeBackslashes = (path) => path.includes("\\\\") ? path : path.replaceAll("\\", "\\\\");
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/path-utils.ts"],
|
|
4
4
|
"sourcesContent": ["import _ from 'lodash'\nimport oslib from 'os'\nimport pathlib from 'path'\n\nexport namespace posix {\n export type AbsolutePath = `/${string}`\n export const isPath = (path: string) => isAbsolutePath(path) || isRelativePath(path)\n export const isRelativePath = (path: string) => path.startsWith('./') || path.startsWith('../')\n export const isAbsolutePath = (path: string): path is AbsolutePath => pathlib.posix.isAbsolute(path)\n}\n\nexport namespace win32 {\n export type AbsolutePath = `${string}:\\\\${string}` // C:\\path\n export const isPath = (path: string) => isAbsolutePath(path) || isRelativePath(path)\n export const isRelativePath = (path: string) => path.startsWith('.\\\\') || path.startsWith('..\\\\')\n export const isAbsolutePath = (path: string): path is AbsolutePath => /^[a-zA-Z]:\\\\/.test(path) // bp cli does not allow omitting the drive letter\n export const escapeBackslashes = (path: string) => (path.includes('\\\\\\\\') ? path : path.replaceAll('\\\\', '\\\\\\\\')) // idempotent function\n}\n\nexport type AbsolutePath = posix.AbsolutePath | win32.AbsolutePath\nexport const isPath = (path: string) => (oslib.platform() === 'win32' ? win32.isPath(path) : posix.isPath(path))\nexport const isAbsolutePath = (path: string): path is AbsolutePath =>\n oslib.platform() === 'win32' ? win32.isAbsolutePath(path) : posix.isAbsolutePath(path)\n\nexport const cwd = (): AbsolutePath => process.cwd() as AbsolutePath\nexport const join = (abs: AbsolutePath, ...paths: string[]): AbsolutePath => {\n const joined = pathlib.join(abs, ...paths)\n return pathlib.normalize(joined) as AbsolutePath\n}\n\nexport const rmExtension = (filename: string) => filename.replace(/\\.[^/.]+$/, '')\n\nexport const toUnix = (path: string) => path.split(pathlib.sep).join(pathlib.posix.sep)\n\nexport const absoluteFrom = (rootdir: AbsolutePath, target: string): AbsolutePath => {\n if (isAbsolutePath(target)) {\n return target\n }\n return pathlib.join(rootdir, target) as AbsolutePath\n}\n\nexport const relativeFrom = (rootdir: AbsolutePath, target: string) => {\n let absPath: string\n\n if (isAbsolutePath(target)) {\n absPath = target\n } else {\n absPath = pathlib.resolve(pathlib.join(rootdir, target))\n }\n\n return pathlib.relative(rootdir, absPath)\n}\n\nexport class PathStore<P extends string> {\n public constructor(public readonly abs: Record<P, AbsolutePath>) {}\n public rel(from: Extract<P, `${string}Dir`>) {\n return _.mapValues(this.abs, (to) => relativeFrom(this.abs[from], to))\n }\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAc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Q,MAAM,GAAG;AAE/E,MAAM,eAAe,CAAC,SAAuB,WAAiC;AACnF,MAAI,eAAe,MAAM,GAAG;AAC1B,WAAO;AAAA,EACT;AACA,SAAO,YAAAA,QAAQ,KAAK,SAAS,MAAM;AACrC;AAEO,MAAM,eAAe,CAAC,SAAuB,WAAmB;AACrE,MAAI;AAEJ,MAAI,eAAe,MAAM,GAAG;AAC1B,cAAU;AAAA,EACZ,OAAO;AACL,cAAU,YAAAA,QAAQ,QAAQ,YAAAA,QAAQ,KAAK,SAAS,MAAM,CAAC;AAAA,EACzD;AAEA,SAAO,YAAAA,QAAQ,SAAS,SAAS,OAAO;AAC1C;AAEO,MAAM,UAA4B;AAAA,EAChC,YAA4B,KAA8B;AAA9B;AAAA,EAA+B;AAAA,EAC3D,IAAI,MAAkC;AAC3C,WAAO,cAAAG,QAAE,UAAU,KAAK,KAAK,CAAC,OAAO,aAAa,KAAK,IAAI,IAAI,GAAG,EAAE,CAAC;AAAA,EACvE;AACF;",
|
|
6
6
|
"names": ["posix", "pathlib", "win32", "oslib", "_"]
|
|
7
7
|
}
|
|
@@ -14,6 +14,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
14
14
|
return to;
|
|
15
15
|
};
|
|
16
16
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
17
21
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
18
22
|
mod
|
|
19
23
|
));
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/path-utils.test.ts"],
|
|
4
4
|
"sourcesContent": ["import { test, expect, describe } from 'vitest'\nimport * as pathUtils from './path-utils'\n\ndescribe('posix', () => {\n test('isPath with valid relative path should return true', () => {\n expect(pathUtils.posix.isPath('./src')).toBe(true)\n expect(pathUtils.posix.isPath('../src')).toBe(true)\n expect(pathUtils.posix.isPath('./src/services')).toBe(true)\n expect(pathUtils.posix.isPath('./src/services/index.ts')).toBe(true)\n expect(pathUtils.posix.isPath('./.././.././../lol.json')).toBe(true)\n })\n\n test('isPath with valid absolute path should return true', () => {\n expect(pathUtils.posix.isPath('/src')).toBe(true)\n expect(pathUtils.posix.isPath('/src')).toBe(true)\n expect(pathUtils.posix.isPath('/src/services')).toBe(true)\n expect(pathUtils.posix.isPath('/src/services/index.ts')).toBe(true)\n })\n\n test('isPath with invalid path should return false', () => {\n // these are technically valid posix paths, but not for the bp cli\n expect(pathUtils.posix.isPath('src')).toBe(false)\n expect(pathUtils.posix.isPath('.src')).toBe(false)\n expect(pathUtils.posix.isPath('..src')).toBe(false)\n expect(pathUtils.posix.isPath('src/services')).toBe(false)\n expect(pathUtils.posix.isPath('src/services/index.ts')).toBe(false)\n })\n})\n\ndescribe('win32', () => {\n test('isPath with valid relative path should return true', () => {\n expect(pathUtils.win32.isPath('.\\\\src')).toBe(true)\n expect(pathUtils.win32.isPath('..\\\\src')).toBe(true)\n expect(pathUtils.win32.isPath('.\\\\src\\\\services')).toBe(true)\n expect(pathUtils.win32.isPath('.\\\\src\\\\services\\\\index.ts')).toBe(true)\n expect(pathUtils.win32.isPath('.\\\\..\\\\.\\\\..\\\\.\\\\..\\\\lol.json')).toBe(true)\n })\n\n test('isPath with valid absolute path should return true', () => {\n expect(pathUtils.win32.isPath('C:\\\\src')).toBe(true)\n expect(pathUtils.win32.isPath('C:\\\\src')).toBe(true)\n expect(pathUtils.win32.isPath('C:\\\\src\\\\services')).toBe(true)\n expect(pathUtils.win32.isPath('C:\\\\src\\\\services\\\\index.ts')).toBe(true)\n })\n\n test('isPath with invalid path should return false', () => {\n // these are technically valid win32 paths, but not for the bp cli\n expect(pathUtils.win32.isPath('src')).toBe(false)\n expect(pathUtils.win32.isPath('.src')).toBe(false)\n expect(pathUtils.win32.isPath('..src')).toBe(false)\n expect(pathUtils.win32.isPath('src\\\\services')).toBe(false)\n expect(pathUtils.win32.isPath('src\\\\services\\\\index.ts')).toBe(false)\n expect(pathUtils.win32.isPath('\\\\services')).toBe(false)\n expect(pathUtils.win32.isPath('\\\\services\\\\index.ts')).toBe(false)\n })\n})\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA,oBAAuC;AACvC,gBAA2B;AAAA,IAE3B,wBAAS,SAAS,MAAM;AACtB,0BAAK,sDAAsD,MAAM;AAC/D,8BAAO,UAAU,MAAM,OAAO,OAAO,CAAC,EAAE,KAAK,IAAI;AACjD,8BAAO,UAAU,MAAM,OAAO,QAAQ,CAAC,EAAE,KAAK,IAAI;AAClD,8BAAO,UAAU,MAAM,OAAO,gBAAgB,CAAC,EAAE,KAAK,IAAI;AAC1D,8BAAO,UAAU,MAAM,OAAO,yBAAyB,CAAC,EAAE,KAAK,IAAI;AACnE,8BAAO,UAAU,MAAM,OAAO,yBAAyB,CAAC,EAAE,KAAK,IAAI;AAAA,EACrE,CAAC;AAED,0BAAK,sDAAsD,MAAM;AAC/D,8BAAO,UAAU,MAAM,OAAO,MAAM,CAAC,EAAE,KAAK,IAAI;AAChD,8BAAO,UAAU,MAAM,OAAO,MAAM,CAAC,EAAE,KAAK,IAAI;AAChD,8BAAO,UAAU,MAAM,OAAO,eAAe,CAAC,EAAE,KAAK,IAAI;AACzD,8BAAO,UAAU,MAAM,OAAO,wBAAwB,CAAC,EAAE,KAAK,IAAI;AAAA,EACpE,CAAC;AAED,0BAAK,gDAAgD,MAAM;AAEzD,8BAAO,UAAU,MAAM,OAAO,KAAK,CAAC,EAAE,KAAK,KAAK;AAChD,8BAAO,UAAU,MAAM,OAAO,MAAM,CAAC,EAAE,KAAK,KAAK;AACjD,8BAAO,UA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pE,8BAAO,UAAU,MAAM,OAAO,YAAY,CAAC,EAAE,KAAK,KAAK;AACvD,8BAAO,UAAU,MAAM,OAAO,sBAAsB,CAAC,EAAE,KAAK,KAAK;AAAA,EACnE,CAAC;AACH,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -18,6 +18,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
20
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
25
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
26
|
mod
|
|
23
27
|
));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/pkgjson-utils.ts"],
|
|
4
|
-
"sourcesContent": ["import fs from 'fs'\nimport pathlib from 'path'\n\nexport type PackageJson = {\n name: string\n version?: string\n description?: string\n scripts?: Record<string, string>\n dependencies?: Record<string, string>\n devDependencies?: Record<string, string>\n peerDependencies?: Record<string, string>\n}\n\nconst FILE_NAME = 'package.json'\n\nexport const readPackageJson = async (path: string): Promise<PackageJson | undefined> => {\n const filePath = pathlib.basename(path) === FILE_NAME ? path : pathlib.join(path, FILE_NAME)\n if (!fs.existsSync(filePath)) {\n return undefined\n }\n\n const strContent: string = await fs.promises.readFile(filePath, 'utf8')\n const jsonContent = JSON.parse(strContent)\n return jsonContent\n}\n\nexport const findDependency = (pkgJson: PackageJson, name: string): string | undefined => {\n const { dependencies, devDependencies, peerDependencies } = pkgJson\n const allDependencies = { ...(dependencies ?? {}), ...(devDependencies ?? {}), ...(peerDependencies ?? {}) }\n return allDependencies[name]\n}\n"],
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import fs from 'fs'\nimport pathlib from 'path'\n\ntype JSON = string | number | boolean | null | JSON[] | { [key: string]: JSON }\n\nexport type PackageJson = {\n name: string\n version?: string\n description?: string\n scripts?: Record<string, string>\n dependencies?: Record<string, string>\n devDependencies?: Record<string, string>\n peerDependencies?: Record<string, string>\n} & {\n [key: string]: JSON\n}\n\nconst FILE_NAME = 'package.json'\n\nexport const readPackageJson = async (path: string): Promise<PackageJson | undefined> => {\n const filePath = pathlib.basename(path) === FILE_NAME ? path : pathlib.join(path, FILE_NAME)\n if (!fs.existsSync(filePath)) {\n return undefined\n }\n\n const strContent: string = await fs.promises.readFile(filePath, 'utf8')\n const jsonContent = JSON.parse(strContent)\n return jsonContent\n}\n\nexport const findDependency = (pkgJson: PackageJson, name: string): string | undefined => {\n const { dependencies, devDependencies, peerDependencies } = pkgJson\n const allDependencies = { ...(dependencies ?? {}), ...(devDependencies ?? {}), ...(peerDependencies ?? {}) }\n return allDependencies[name]\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAe;AACf,kBAAoB;AAgBpB,MAAM,YAAY;AAEX,MAAM,kBAAkB,OAAO,SAAmD;AACvF,QAAM,WAAW,YAAAA,QAAQ,SAAS,IAAI,MAAM,YAAY,OAAO,YAAAA,QAAQ,KAAK,MAAM,SAAS;AAC3F,MAAI,CAAC,UAAAC,QAAG,WAAW,QAAQ,GAAG;AAC5B,WAAO;AAAA,EACT;AAEA,QAAM,aAAqB,MAAM,UAAAA,QAAG,SAAS,SAAS,UAAU,MAAM;AACtE,QAAM,cAAc,KAAK,MAAM,UAAU;AACzC,SAAO;AACT;AAEO,MAAM,iBAAiB,CAAC,SAAsB,SAAqC;AACxF,QAAM,EAAE,cAAc,iBAAiB,iBAAiB,IAAI;AAC5D,QAAM,kBAAkB,EAAE,GAAI,gBAAgB,CAAC,GAAI,GAAI,mBAAmB,CAAC,GAAI,GAAI,oBAAoB,CAAC,EAAG;AAC3G,SAAO,gBAAgB,IAAI;AAC7B;",
|
|
6
6
|
"names": ["pathlib", "fs"]
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/promise-utils.ts"],
|
|
4
4
|
"sourcesContent": ["export const awaitRecord = async <T>(record: Record<string, Promise<T>>): Promise<Record<string, T>> => {\n const keys = Object.keys(record)\n const values = await Promise.all(Object.values(record))\n return keys.reduce((acc, key, index) => ({ ...acc, [key]: values[index] }), {})\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,cAAc,OAAU,WAAmE;AACtG,QAAM,OAAO,OAAO,KAAK,MAAM;AAC/B,QAAM,SAAS,MAAM,QAAQ,IAAI,OAAO,OAAO,MAAM,CAAC;AACtD,SAAO,KAAK,OAAO,CAAC,KAAK,KAAK,WAAW,EAAE,GAAG,KAAK,CAAC,
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,cAAc,OAAU,WAAmE;AACtG,QAAM,OAAO,OAAO,KAAK,MAAM;AAC/B,QAAM,SAAS,MAAM,QAAQ,IAAI,OAAO,OAAO,MAAM,CAAC;AACtD,SAAO,KAAK,OAAO,CAAC,KAAK,KAAK,WAAW,EAAE,GAAG,KAAK,CAAC,GAAG,GAAG,OAAO,KAAK,EAAE,IAAI,CAAC,CAAC;AAChF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -18,6 +18,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
20
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
25
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
26
|
mod
|
|
23
27
|
));
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/prompt-utils.ts"],
|
|
4
4
|
"sourcesContent": ["import prompts from 'prompts'\nimport type { Logger } from '../logger'\n\nexport type CLIPromptsProps = {\n confirm: boolean\n}\n\nexport type CLIPromptsChoice<V extends string> = {\n title: string\n value: V\n}\n\ntype PasswordOptions = Partial<{\n default: string | undefined\n initial: string\n}>\ntype SelectOptions<V extends string> = Partial<{\n default: V | undefined\n initial: CLIPromptsChoice<V>\n choices: CLIPromptsChoice<V>[]\n}>\ntype TextOptions = Partial<{\n default: string | undefined\n initial: string\n}>\n\nexport class CLIPrompt {\n public constructor(private _props: CLIPromptsProps, private _logger: Logger) {}\n\n public async confirm(message: string): Promise<boolean> {\n if (this._props.confirm) {\n this._logger.debug(`Confirming automatically (non-interactive mode): ${message}`)\n return true\n }\n\n const { confirm } = await this._prompts({\n type: 'confirm',\n name: 'confirm',\n message,\n initial: false,\n })\n\n if (!confirm) {\n return false\n }\n return true\n }\n\n public async password(message: string, opts: PasswordOptions = {}): Promise<string | undefined> {\n if (this._props.confirm) {\n this._logger.debug(`Return default (non-interactive mode): ${message}`)\n return opts?.default\n }\n\n const { prompted } = await this._prompts({\n type: 'password',\n name: 'prompted',\n message,\n initial: opts?.initial,\n })\n\n return prompted ? prompted : undefined\n }\n\n public async select<V extends string>(message: string, opts: SelectOptions<V> = {}): Promise<V | undefined> {\n if (this._props.confirm) {\n this._logger.debug(`Return default (non-interactive mode): ${message}`)\n return opts?.default\n }\n\n const { prompted } = await this._prompts({\n type: 'autocomplete',\n name: 'prompted',\n message,\n initial: opts?.initial?.value,\n choices: opts?.choices,\n })\n return prompted ? prompted : undefined\n }\n\n public async text(message: string, opts: TextOptions = {}): Promise<string | undefined> {\n if (this._props.confirm) {\n this._logger.debug(`Return default (non-interactive mode): ${message}`)\n return opts?.default\n }\n\n const { prompted } = await this._prompts({\n type: 'text',\n name: 'prompted',\n message,\n initial: opts?.initial,\n })\n\n return prompted ? prompted : undefined\n }\n\n private _prompts = (...args: Parameters<typeof prompts>): ReturnType<typeof prompts> => {\n this._logger.cleanup()\n return prompts(...args)\n }\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAoB;AA0Bb,MAAM,UAAU;AAAA,EACd,YAAoB,QAAiC,SAAiB;AAAlD;AAAiC;AAAA,EAAkB;AAAA,EAE9E,MAAa,QAAQ,SAAmC;AACtD,QAAI,KAAK,OAAO,SAAS;AACvB,WAAK,QAAQ,MAAM,oDAAoD,SAAS;AAChF,aAAO;AAAA,IACT;AAEA,UAAM,EAAE,QAAQ,IAAI,MAAM,KAAK,SAAS;AAAA,MACtC,MAAM;AAAA,MACN,MAAM;AAAA,MACN;AAAA,MACA,SAAS;AAAA,IACX,CAAC;AAED,QAAI,CAAC,SAAS;AACZ,aAAO;AAAA,IACT;AACA,WAAO;AAAA,EACT;AAAA,EAEA,MAAa,SAAS,SAAiB,OAAwB,CAAC,GAAgC;AAC9F,QAAI,KAAK,OAAO,SAAS;AACvB,WAAK,QAAQ,MAAM,0CAA0C,SAAS;AACtE,aAAO,MAAM;AAAA,IACf;AAEA,UAAM,EAAE,SAAS,IAAI,MAAM,KAAK,SAAS;AAAA,MACvC,MAAM;AAAA,MACN,MAAM;AAAA,MACN;AAAA,MACA,SAAS,MAAM;AAAA,IACjB,CAAC;AAED,WAAO,WAAW,WAAW;AAAA,EAC/B;AAAA,EAEA,MAAa,OAAyB,SAAiB,OAAyB,CAAC,GAA2B;AAC1G,QAAI,KAAK,OAAO,SAAS;AACvB,WAAK,QAAQ,MAAM,0CAA0C,SAAS;AACtE,aAAO,MAAM;AAAA,IACf;AAEA,UAAM,EAAE,SAAS,IAAI,MAAM,KAAK,SAAS;AAAA,MACvC,MAAM;AAAA,MACN,MAAM;AAAA,MACN;AAAA,MACA,SAAS,MAAM,SAAS;AAAA,MACxB,SAAS,MAAM;AAAA,IACjB,CAAC;AACD,WAAO,WAAW,WAAW;AAAA,EAC/B;AAAA,EAEA,MAAa,KAAK,SAAiB,OAAoB,CAAC,GAAgC;AACtF,QAAI,KAAK,OAAO,SAAS;AACvB,WAAK,QAAQ,MAAM,0CAA0C,SAAS;AACtE,aAAO,MAAM;AAAA,IACf;AAEA,UAAM,EAAE,SAAS,IAAI,MAAM,KAAK,SAAS;AAAA,MACvC,MAAM;AAAA,MACN,MAAM;AAAA,MACN;AAAA,MACA,SAAS,MAAM;AAAA,IACjB,CAAC;AAED,WAAO,WAAW,WAAW;AAAA,EAC/B;AAAA,EAEQ,WAAW,IAAI,SAAiE;AACtF,SAAK,QAAQ,QAAQ;AACrB,eAAO,eAAAA,SAAQ,GAAG,IAAI;AAAA,EACxB;AACF;",
|
|
6
6
|
"names": ["prompts"]
|
|
7
7
|
}
|
|
@@ -18,6 +18,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
20
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
25
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
26
|
mod
|
|
23
27
|
));
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/record-utils.ts"],
|
|
4
4
|
"sourcesContent": ["import _ from 'lodash'\n\nexport const setNullOnMissingValues = <A, B>(\n record: Record<string, A> = {},\n oldRecord: Record<string, B> = {}\n): Record<string, A | null> => {\n const newRecord: Record<string, A | null> = {}\n\n for (const [key, value] of Object.entries(record)) {\n newRecord[key] = value\n }\n\n for (const value of Object.keys(oldRecord)) {\n if (!record[value]) {\n newRecord[value] = null\n }\n }\n\n return newRecord\n}\n\nexport const zipObjects = <A, B>(\n recordA: Record<string, A>,\n recordB: Record<string, B>\n): Record<string, [A | null, B | null]> => {\n const allKeys = new Set([...Object.keys(recordA), ...Object.keys(recordB)])\n const newRecord: Record<string, [A | null, B | null]> = {}\n\n for (const key of allKeys) {\n newRecord[key] = [recordA[key] ?? null, recordB[key] ?? null]\n }\n\n return newRecord\n}\n\nexport const mapValues = <A, B>(record: Record<string, A>, fn: (value: A, key: string) => B): Record<string, B> => {\n const newRecord: Record<string, B> = {}\n\n for (const [key, value] of Object.entries(record)) {\n newRecord[key] = fn(value, key)\n }\n\n return newRecord\n}\n\nexport const mapValuesAsync = async <A, B>(\n record: Record<string, A>,\n fn: (value: A, key: string) => Promise<B>\n): Promise<Record<string, B>> => {\n const newRecord: Record<string, B> = {}\n\n for (const [key, value] of Object.entries(record)) {\n newRecord[key] = await fn(value, key)\n }\n\n return newRecord\n}\n\nexport const mapKeys = <A>(record: Record<string, A>, fn: (value: A, key: string) => string): Record<string, A> => {\n const newRecord: Record<string, A> = {}\n\n for (const [key, value] of Object.entries(record)) {\n const newKey = fn(value, key) as string\n newRecord[newKey] = value\n }\n\n return newRecord\n}\n\nexport function filterValues<A, B extends A>(\n record: Record<string, A>,\n fn: (value: A, key: string) => value is B\n): Record<string, B>\nexport function filterValues<A, _B extends A>(\n record: Record<string, A>,\n fn: (value: A, key: string) => boolean\n): Record<string, A>\nexport function filterValues<A>(record: Record<string, A>, fn: (value: A, key: string) => boolean) {\n const newRecord: Record<string, A> = {}\n\n for (const [key, value] of Object.entries(record)) {\n if (fn(value, key)) {\n newRecord[key] = value\n }\n }\n\n return newRecord\n}\n\nexport const mergeRecords = <K extends string, V>(\n a: Record<K, V>,\n b: Record<K, V>,\n merge: (v1: V, v2: V) => V\n): Record<K, V> => {\n const keys = _.uniq([...Object.keys(a), ...Object.keys(b)]) as K[]\n const result: Record<K, V> = {} as Record<K, V>\n for (const key of keys) {\n const aValue = a[key]\n const bValue = b[key]\n if (aValue && bValue) {\n result[key] = merge(aValue, bValue)\n } else if (aValue) {\n result[key] = aValue\n } else if (bValue) {\n result[key] = bValue\n }\n }\n return result\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAc;AAEP,MAAM,yBAAyB,CACpC,SAA4B,CAAC,GAC7B,YAA+B,CAAC,MACH;AAC7B,QAAM,YAAsC,CAAC;AAE7C,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,MAAM,GAAG;AACjD,cAAU,GAAG,IAAI;AAAA,EACnB;AAEA,aAAW,SAAS,OAAO,KAAK,SAAS,GAAG;AAC1C,QAAI,CAAC,OAAO,KAAK,GAAG;AAClB,gBAAU,KAAK,IAAI;AAAA,IACrB;AAAA,EACF;AAEA,SAAO;AACT;AAEO,MAAM,aAAa,CACxB,SACA,YACyC;AACzC,QAAM,UAAU,oBAAI,IAAI,CAAC,GAAG,OAAO,KAAK,OAAO,GAAG,GAAG,OAAO,KAAK,OAAO,CAAC,CAAC;AAC1E,QAAM,YAAkD,CAAC;AAEzD,aAAW,OAAO,SAAS;AACzB,cAAU,GAAG,IAAI,CAAC,QAAQ,GAAG,KAAK,MAAM,QAAQ,GAAG,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,QAAQ;AACjB,aAAO,GAAG,IAAI;AAAA,IAChB,WAAW,QAAQ;AACjB,aAAO,GAAG,IAAI;AAAA,IAChB;AAAA,EACF;AACA,SAAO;AACT;",
|
|
6
6
|
"names": ["_"]
|
|
7
7
|
}
|
|
@@ -14,6 +14,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
14
14
|
return to;
|
|
15
15
|
};
|
|
16
16
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
17
21
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
18
22
|
mod
|
|
19
23
|
));
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/record-utils.test.ts"],
|
|
4
4
|
"sourcesContent": ["import { test, expect } from 'vitest'\nimport * as recordUtils from './record-utils'\n\ntest('zip objects should return both values only when key is defined in both objects', () => {\n const objA = { a: 1, b: 2, c: 3 }\n const objB = { c: 4, d: 5 }\n\n const zipped = recordUtils.zipObjects(objA, objB)\n\n const expected = {\n a: [1, null],\n b: [2, null],\n c: [3, 4],\n d: [null, 5],\n }\n\n expect(zipped).toEqual(expected)\n})\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA,oBAA6B;AAC7B,kBAA6B;AAAA,IAE7B,oBAAK,kFAAkF,MAAM;AAC3F,QAAM,OAAO,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,EAAE;AAChC,QAAM,OAAO,EAAE,GAAG,GAAG,GAAG,EAAE;AAE1B,QAAM,SAAS,YAAY,WAAW,MAAM,IAAI;AAEhD,QAAM,WAAW;AAAA,IACf,GAAG,CAAC,GAAG,IAAI;AAAA,IACX,GAAG,CAAC,GAAG,IAAI;AAAA,IACX,GAAG,CAAC,GAAG,CAAC;AAAA,IACR,GAAG,CAAC,MAAM,CAAC;AAAA,EACb;AAEA,4BAAO,MAAM,EAAE,QAAQ,QAAQ;AACjC,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -18,6 +18,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
20
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
25
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
26
|
mod
|
|
23
27
|
));
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/require-utils.ts"],
|
|
4
4
|
"sourcesContent": ["import Module from 'module'\nimport pathlib from 'path'\n\nexport const requireJsFile = <T>(path: string): T => {\n return require(path)\n}\n\nexport const requireJsCode = <T>(code: string): T => {\n const filedir = 'tmp'\n const filename = `${Date.now()}.js`\n\n const fileid = pathlib.join(filedir, filename)\n\n const m = new Module(fileid)\n m.filename = filename\n\n try {\n // @ts-ignore\n m._compile(code, filename)\n return m.exports\n } catch (thrown: unknown) {\n const error = thrown instanceof Error ? thrown : new Error(`${thrown}`)\n throw _injectStackTrace(error, code, filename)\n }\n}\n\nconst STACK_TRACE_SURROUNDING_LINES = 3\n\nconst _injectStackTrace = (compileError: Error, code: string, filename: string): Error => {\n if (!compileError.stack || !compileError.stack.includes(`${filename}:`)) {\n return compileError\n }\n\n // Extract line and column from the stack trace:\n const [, locationInfo] = compileError.stack.split(`${filename}:`, 2)\n if (!locationInfo) {\n return compileError\n }\n\n const [lineNoStr, _rest] = locationInfo.split(':', 2)\n if (!lineNoStr || !_rest) {\n return compileError\n }\n\n const [columnStr] = _rest.split(')', 1)\n if (!columnStr) {\n return compileError\n }\n\n const lineNo = parseInt(lineNoStr)\n const column = parseInt(columnStr)\n\n // Build the stack trace:\n const allLines = code.split('\\n')\n const linesBefore = allLines.slice(Math.max(0, lineNo - 1 - STACK_TRACE_SURROUNDING_LINES), lineNo - 1)\n const offendingLine = allLines[lineNo - 1]\n const caretLine = ' '.repeat(column - 1) + '^'\n const linesAfter = allLines.slice(lineNo, Math.min(allLines.length, lineNo + STACK_TRACE_SURROUNDING_LINES))\n const stackTrace = [...linesBefore, offendingLine, caretLine, ...linesAfter].join('\\n')\n\n return new Error(`${compileError.message}\\n\\nOffending code:\\n\\n${stackTrace}`, { cause: compileError })\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAmB;AACnB,kBAAoB;AAEb,MAAM,gBAAgB,CAAI,SAAoB;AACnD,SAAO,QAAQ,IAAI;AACrB;AAEO,MAAM,gBAAgB,CAAI,SAAoB;AACnD,QAAM,UAAU;AAChB,QAAM,WAAW,GAAG,KAAK,IAAI;AAE7B,QAAM,SAAS,YAAAA,QAAQ,KAAK,SAAS,QAAQ;AAE7C,QAAM,IAAI,IAAI,cAAAC,QAAO,MAAM;AAC3B,IAAE,WAAW;AAEb,MAAI;AAEF,MAAE,SAAS,MAAM,QAAQ;AACzB,WAAO,EAAE;AAAA,EACX,SAAS,QAAP;AACA,UAAM,QAAQ,kBAAkB,QAAQ,SAAS,IAAI,MAAM,GAAG,QAAQ;AACtE,UAAM,kBAAkB,OAAO,MAAM,QAAQ;AAAA,EAC/C;AACF;AAEA,MAAM,gCAAgC;AAEtC,MAAM,oBAAoB,CAAC,cAAqB,MAAc,aAA4B;AACxF,MAAI,CAAC,aAAa,SAAS,CAAC,aAAa,MAAM,SAAS,GAAG,WAAW,GAAG;AACvE,WAAO;AAAA,EACT;AAGA,QAAM,CAAC,EAAE,YAAY,IAAI,aAAa,MAAM,MAAM,GAAG,aAAa,CAAC;AACnE,MAAI,CAAC,cAAc;AACjB,WAAO;AAAA,EACT;AAEA,QAAM,CAAC,WAAW,KAAK,IAAI,aAAa,MAAM,KAAK,CAAC;AACpD,MAAI,CAAC,aAAa,CAAC,OAAO;AACxB,WAAO;AAAA,EACT;AAEA,QAAM,CAAC,SAAS,IAAI,MAAM,MAAM,KAAK,CAAC;AACtC,MAAI,CAAC,WAAW;AACd,WAAO;AAAA,EACT;AAEA,QAAM,SAAS,SAAS,SAAS;AACjC,QAAM,SAAS,SAAS,SAAS;AAGjC,QAAM,WAAW,KAAK,MAAM,IAAI;AAChC,QAAM,cAAc,SAAS,MAAM,KAAK,IAAI,GAAG,SAAS,IAAI,6BAA6B,GAAG,SAAS,CAAC;AACtG,QAAM,gBAAgB,SAAS,SAAS,CAAC;AACzC,QAAM,YAAY,IAAI,OAAO,SAAS,CAAC,IAAI;AAC3C,QAAM,aAAa,SAAS,MAAM,QAAQ,KAAK,IAAI,SAAS,QAAQ,SAAS,6BAA6B,CAAC;AAC3G,QAAM,aAAa,CAAC,GAAG,aAAa,eAAe,WAAW,GAAG,UAAU,EAAE,KAAK,IAAI;AAEtF,SAAO,IAAI,MAAM,GAAG,aAAa;AAAA;AAAA;AAAA;AAAA,EAAiC,cAAc,EAAE,OAAO,aAAa,CAAC;AACzG;",
|
|
6
6
|
"names": ["pathlib", "Module"]
|
|
7
7
|
}
|
|
@@ -14,6 +14,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
14
14
|
return to;
|
|
15
15
|
};
|
|
16
16
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
17
21
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
18
22
|
mod
|
|
19
23
|
));
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/require-utils.test.ts"],
|
|
4
4
|
"sourcesContent": ["import { test, expect } from 'vitest'\nimport * as requireUtils from './require-utils'\n\ntest('require js code should do as its name suggests', () => {\n const code = `\n module.exports = {\n foo: 'bar'\n }\n `\n\n const result = requireUtils.requireJsCode<{ foo: string }>(code)\n\n expect(result.foo).toBe('bar')\n})\n\nconst getError = (fn: () => void): Error | undefined => {\n try {\n fn()\n return\n } catch (thrown: unknown) {\n return thrown instanceof Error ? thrown : new Error(`${thrown}`)\n }\n}\n\ntest('require js code should indicate issue in stack trace', () => {\n const code = `\n var foo = undefined\n module.exports = {\n bar: foo.bar\n }\n `\n\n const error = getError(() => requireUtils.requireJsCode(code))\n\n expect(error).toBeDefined()\n expect(error?.message).toContain('bar: foo.bar')\n})\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA,oBAA6B;AAC7B,mBAA8B;AAAA,IAE9B,oBAAK,kDAAkD,MAAM;AAC3D,QAAM,OAAO;AAAA;AAAA;AAAA;AAAA;AAMb,QAAM,SAAS,aAAa,cAA+B,IAAI;AAE/D,4BAAO,OAAO,GAAG,EAAE,KAAK,KAAK;AAC/B,CAAC;AAED,MAAM,WAAW,CAAC,OAAsC;AACtD,MAAI;AACF,OAAG;AACH;AAAA,EACF,SAAS,QAAP;AACA,WAAO,kBAAkB,QAAQ,SAAS,IAAI,MAAM,GAAG,QAAQ;AAAA,EACjE;AACF;AAAA,IAEA,oBAAK,wDAAwD,MAAM;AACjE,QAAM,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAOb,QAAM,QAAQ,SAAS,MAAM,aAAa,cAAc,IAAI,CAAC;AAE7D,4BAAO,KAAK,EAAE,YAAY;AAC1B,4BAAO,OAAO,OAAO,EAAE,UAAU,cAAc;AACjD,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/schema-utils.ts"],
|
|
4
4
|
"sourcesContent": ["import { dereference } from '@apidevtools/json-schema-ref-parser'\nimport { z, transforms } from '@botpress/sdk'\nimport { JSONSchema7 } from 'json-schema'\n\ntype ZuiToJsonSchema = typeof transforms.zuiToJsonSchema\ntype JsonSchema = ReturnType<ZuiToJsonSchema>\ntype ObjectJsonSchema = Extract<JsonSchema, { type: 'object' }>\n\ntype SchemaOptions = {\n title?: string\n examples?: any[]\n}\n\ntype ZodObjectSchema = z.ZodObject | z.ZodRecord\ntype SchemaDefinition = {\n schema: ZodObjectSchema\n ui?: Record<string, SchemaOptions | undefined>\n}\n\nconst isObjectSchema = (schema: JsonSchema): schema is ObjectJsonSchema => schema.type === 'object'\n\nexport async function mapZodToJsonSchema(\n definition: SchemaDefinition\n): Promise<ReturnType<typeof transforms.zuiToJsonSchema>> {\n let schema = transforms.zuiToJsonSchema(definition.schema, { target: 'jsonSchema7' })\n schema = (await dereferenceSchema(schema)) as typeof schema\n\n if (!isObjectSchema(schema) || !definition.ui) {\n return schema\n }\n\n for (const [key, value] of Object.entries(definition.ui ?? {})) {\n const property = schema.properties?.[key]\n\n if (!property) {\n continue\n }\n\n if (!!value?.title) {\n ;(property as any).title = value.title\n }\n\n if (!!value?.examples) {\n ;(property as any).examples = value.examples\n }\n }\n\n return schema\n}\n\nexport const dereferenceSchema = async (schema: JSONSchema7): Promise<JSONSchema7> => {\n return dereference(schema, {\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A,SAAO;AACT;AAEO,MAAM,oBAAoB,OAAO,WAA8C;AACpF,aAAO,2CAAY,QAAQ;AAAA,IACzB,SAAS;AAAA,MACP,UAAU;AAAA,MACV,MAAM;AAAA,MACN,MAAM;AAAA,IACR;AAAA,EACF,CAAC;AACH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/semver-utils.ts"],
|
|
4
4
|
"sourcesContent": ["import semver from 'semver'\n\nconst semverReleases: Record<semver.ReleaseType, number> = {\n prerelease: 0,\n prepatch: 1,\n patch: 2,\n preminor: 3,\n minor: 4,\n premajor: 5,\n major: 6,\n}\n\nexport namespace releases {\n export const eq = (a: semver.ReleaseType, b: semver.ReleaseType) => semverReleases[a] === semverReleases[b]\n export const gt = (a: semver.ReleaseType, b: semver.ReleaseType) => semverReleases[a] > semverReleases[b]\n export const gte = (a: semver.ReleaseType, b: semver.ReleaseType) => semverReleases[a] >= semverReleases[b]\n export const lt = (a: semver.ReleaseType, b: semver.ReleaseType) => semverReleases[a] < semverReleases[b]\n export const lte = (a: semver.ReleaseType, b: semver.ReleaseType) => semverReleases[a] <= semverReleases[b]\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,MAAM,iBAAqD;AAAA,EACzD,YAAY;AAAA,EACZ,UAAU;AAAA,EACV,OAAO;AAAA,EACP,UAAU;AAAA,EACV,OAAO;AAAA,EACP,UAAU;AAAA,EACV,OAAO;AACT;AAEO,IAAU;AAAA,CAAV,CAAUA,cAAV;AACE,EAAMA,UAAA,KAAK,CAAC,GAAuB,MAA0B,eAAe,
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,MAAM,iBAAqD;AAAA,EACzD,YAAY;AAAA,EACZ,UAAU;AAAA,EACV,OAAO;AAAA,EACP,UAAU;AAAA,EACV,OAAO;AAAA,EACP,UAAU;AAAA,EACV,OAAO;AACT;AAEO,IAAU;AAAA,CAAV,CAAUA,cAAV;AACE,EAAMA,UAAA,KAAK,CAAC,GAAuB,MAA0B,eAAe,CAAC,MAAM,eAAe,CAAC;AACnG,EAAMA,UAAA,KAAK,CAAC,GAAuB,MAA0B,eAAe,CAAC,IAAI,eAAe,CAAC;AACjG,EAAMA,UAAA,MAAM,CAAC,GAAuB,MAA0B,eAAe,CAAC,KAAK,eAAe,CAAC;AACnG,EAAMA,UAAA,KAAK,CAAC,GAAuB,MAA0B,eAAe,CAAC,IAAI,eAAe,CAAC;AACjG,EAAMA,UAAA,MAAM,CAAC,GAAuB,MAA0B,eAAe,CAAC,KAAK,eAAe,CAAC;AAAA,GAL3F;",
|
|
6
6
|
"names": ["releases"]
|
|
7
7
|
}
|
|
@@ -18,6 +18,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
20
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
25
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
26
|
mod
|
|
23
27
|
));
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/template-utils.ts"],
|
|
4
4
|
"sourcesContent": ["import hb from 'handlebars'\nimport * as casing from './case-utils'\n\nhb.registerHelper('toUpperCase', (s) => s.toUpperCase())\nhb.registerHelper('toLowerCase', (s) => s.toLowerCase())\nhb.registerHelper('pascalCase', casing.to.pascalCase)\nhb.registerHelper('kebabCase', casing.to.kebabCase)\nhb.registerHelper('snakeCase', casing.to.snakeCase)\nhb.registerHelper('screamingSnakeCase', casing.to.screamingSnakeCase)\nhb.registerHelper('camelCase', casing.to.camelCase)\n\nexport const formatHandleBars = (templateStr: string, data: Record<string, string>): string => {\n const template = hb.compile(templateStr)\n return template(data)\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAe;AACf,aAAwB;AAExB,kBAAAA,QAAG,eAAe,eAAe,CAAC,MAAM,EAAE,YAAY,CAAC;AACvD,kBAAAA,QAAG,eAAe,eAAe,CAAC,MAAM,EAAE,YAAY,CAAC;AACvD,kBAAAA,QAAG,eAAe,cAAc,OAAO,GAAG,UAAU;AACpD,kBAAAA,QAAG,eAAe,aAAa,OAAO,GAAG,SAAS;AAClD,kBAAAA,QAAG,eAAe,aAAa,OAAO,GAAG,SAAS;AAClD,kBAAAA,QAAG,eAAe,sBAAsB,OAAO,GAAG,kBAAkB;AACpE,kBAAAA,QAAG,eAAe,aAAa,OAAO,GAAG,SAAS;AAE3C,MAAM,mBAAmB,CAAC,aAAqB,SAAyC;AAC7F,QAAM,WAAW,kBAAAA,QAAG,QAAQ,WAAW;AACvC,SAAO,SAAS,IAAI;AACtB;",
|
|
6
6
|
"names": ["hb"]
|
|
7
7
|
}
|
|
@@ -64,6 +64,9 @@ class TunnelSupervisor {
|
|
|
64
64
|
get closed() {
|
|
65
65
|
return this._closed;
|
|
66
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* @returns Promise that rejects when a reconnection attempt fails and resolves when the tunnel is closed manually
|
|
69
|
+
*/
|
|
67
70
|
async wait() {
|
|
68
71
|
if (this._closed) {
|
|
69
72
|
throw new Error("Cannot wait: Tunnel is closed");
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/tunnel-utils.ts"],
|
|
4
4
|
"sourcesContent": ["import { TunnelTail, ClientCloseEvent, ClientErrorEvent } from '@bpinternal/tunnel'\nimport { Logger } from '../logger'\nimport { EventEmitter } from './event-emitter'\n\nexport type ReconnectionTriggerEvent =\n | {\n type: 'init'\n ev: null\n }\n | {\n type: 'error'\n ev: ClientErrorEvent\n }\n | {\n type: 'close'\n ev: ClientCloseEvent\n }\n\nexport type ReconnectedEvent = {\n tunnel: TunnelTail\n ev: ReconnectionTriggerEvent\n}\n\nexport class ReconnectionFailedError extends Error {\n public constructor(public readonly event: ReconnectionTriggerEvent) {\n const reason = ReconnectionFailedError._reason(event)\n super(`Reconnection failed: ${reason}`)\n }\n\n private static _reason(event: ReconnectionTriggerEvent): string {\n if (event.type === 'error') {\n return 'error'\n }\n\n if (event.type === 'close') {\n return `${event.ev.code} ${event.ev.reason}`\n }\n\n return 'init'\n }\n}\n\nexport class TunnelSupervisor {\n private _tunnel?: TunnelTail\n private _closed = false\n private _started = false\n\n public readonly events = new EventEmitter<{\n connectionFailed: ReconnectionTriggerEvent\n manuallyClosed: null\n connected: {\n tunnel: TunnelTail\n ev: ReconnectionTriggerEvent\n }\n }>()\n\n public constructor(private _tunnelUrl: string, private _tunnelId: string, private _logger: Logger) {}\n\n public async start(): Promise<void> {\n if (this._closed) {\n throw new Error('Cannot start: Tunnel is closed')\n }\n if (this._started) {\n throw new Error('Cannot start: Tunnel is already started')\n }\n\n this._started = true\n const tunnel = await this._reconnect({ type: 'init', ev: null })\n this._tunnel = tunnel\n }\n\n public get closed(): boolean {\n return this._closed\n }\n\n /**\n * @returns Promise that rejects when a reconnection attempt fails and resolves when the tunnel is closed manually\n */\n public async wait(): Promise<void> {\n if (this._closed) {\n throw new Error('Cannot wait: Tunnel is closed')\n }\n\n return new Promise((resolve, reject) => {\n this.events.on('connectionFailed', (ev) => {\n reject(new ReconnectionFailedError(ev))\n })\n\n this.events.on('manuallyClosed', () => {\n resolve()\n })\n })\n }\n\n public close(): void {\n if (this._closed) {\n return\n }\n\n this._closed = true\n this._tunnel?.close()\n this.events.emit('manuallyClosed', null)\n }\n\n private _reconnectSync(ev: ReconnectionTriggerEvent): void {\n void this._reconnect(ev)\n .then((t) => {\n this._tunnel = t\n })\n .catch(() => this.events.emit('connectionFailed', ev))\n }\n\n private async _reconnect(ev: ReconnectionTriggerEvent): Promise<TunnelTail> {\n const newTunnel = async () => {\n const tunnel = await TunnelTail.new(this._tunnelUrl, this._tunnelId)\n this._registerListeners(tunnel)\n this.events.emit('connected', { tunnel, ev })\n return tunnel\n }\n\n if (ev.type === 'init') {\n // skip logging on the first connection attempt\n return newTunnel()\n }\n\n const line = this._logger.line()\n line.started('Reconnecting tunnel...')\n const tunnel = await newTunnel()\n line.success('Reconnected')\n line.commit()\n return tunnel\n }\n\n private _registerListeners(tunnel: TunnelTail) {\n tunnel.events.on('error', ({ target, type }) => {\n this._logger.error(`Tunnel error: ${type}`)\n this._reconnectSync({ type: 'error', ev: { target, type } })\n })\n tunnel.events.on('close', ({ code, reason, target, type, wasClean }) => {\n this._logger.error(`Tunnel closed: ${code} ${reason}`)\n this._reconnectSync({ type: 'close', ev: { code, reason, target, type, wasClean } })\n })\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA+D;AAE/D,2BAA6B;AAqBtB,MAAM,gCAAgC,MAAM;AAAA,EAC1C,YAA4B,OAAiC;AAClE,UAAM,SAAS,wBAAwB,QAAQ,KAAK;AACpD,UAAM,wBAAwB,QAAQ;AAFL;AAAA,EAGnC;AAAA,EAEA,OAAe,QAAQ,OAAyC;AAC9D,QAAI,MAAM,SAAS,SAAS;AAC1B,aAAO;AAAA,IACT;AAEA,QAAI,MAAM,SAAS,SAAS;AAC1B,aAAO,GAAG,MAAM,GAAG,QAAQ,MAAM,GAAG;AAAA,IACtC;AAEA,WAAO;AAAA,EACT;AACF;AAEO,MAAM,iBAAiB;AAAA,EAcrB,YAAoB,YAA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M,KAAK,OAAO,KAAK,oBAAoB,EAAE,CAAC;AAAA,EACzD;AAAA,EAEA,MAAc,WAAW,IAAmD;AAC1E,UAAM,YAAY,YAAY;AAC5B,YAAMA,UAAS,MAAM,yBAAW,IAAI,KAAK,YAAY,KAAK,SAAS;AACnE,WAAK,mBAAmBA,OAAM;AAC9B,WAAK,OAAO,KAAK,aAAa,EAAE,QAAAA,SAAQ,GAAG,CAAC;AAC5C,aAAOA;AAAA,IACT;AAEA,QAAI,GAAG,SAAS,QAAQ;AAEtB,aAAO,UAAU;AAAA,IACnB;AAEA,UAAM,OAAO,KAAK,QAAQ,KAAK;AAC/B,SAAK,QAAQ,wBAAwB;AACrC,UAAM,SAAS,MAAM,UAAU;AAC/B,SAAK,QAAQ,aAAa;AAC1B,SAAK,OAAO;AACZ,WAAO;AAAA,EACT;AAAA,EAEQ,mBAAmB,QAAoB;AAC7C,WAAO,OAAO,GAAG,SAAS,CAAC,EAAE,QAAQ,KAAK,MAAM;AAC9C,WAAK,QAAQ,MAAM,iBAAiB,MAAM;AAC1C,WAAK,eAAe,EAAE,MAAM,SAAS,IAAI,EAAE,QAAQ,KAAK,EAAE,CAAC;AAAA,IAC7D,CAAC;AACD,WAAO,OAAO,GAAG,SAAS,CAAC,EAAE,MAAM,QAAQ,QAAQ,MAAM,SAAS,MAAM;AACtE,WAAK,QAAQ,MAAM,kBAAkB,QAAQ,QAAQ;AACrD,WAAK,eAAe,EAAE,MAAM,SAAS,IAAI,EAAE,MAAM,QAAQ,QAAQ,MAAM,SAAS,EAAE,CAAC;AAAA,IACrF,CAAC;AAAA,EACH;AACF;",
|
|
6
6
|
"names": ["tunnel"]
|
|
7
7
|
}
|
|
@@ -18,6 +18,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
20
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
25
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
26
|
mod
|
|
23
27
|
));
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/worker/child-entrypoint.ts"],
|
|
4
4
|
"sourcesContent": ["import * as utils from '../utils'\nimport { CONFIG_ENV_KEY, configSchema } from './config'\nimport { ChildProcessProps, processProps } from './is-child'\n\nexport const ENTRY_POINT = __filename\n\nconst childProcessEntrypoint = async (_props: ChildProcessProps) => {\n const rawConfig = process.env[CONFIG_ENV_KEY]\n if (!rawConfig) {\n throw new Error(`Config variable ${CONFIG_ENV_KEY} was not set`)\n }\n const config = configSchema.parse(JSON.parse(rawConfig))\n\n if (config.type === 'code') {\n utils.require.requireJsCode(config.code)\n }\n if (config.type === 'file') {\n utils.require.requireJsFile(config.file)\n }\n}\n\nif (processProps.type === 'child') {\n // here we are in the child process\n void childProcessEntrypoint(processProps)\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,YAAuB;AACvB,oBAA6C;AAC7C,sBAAgD;AAEzC,MAAM,cAAc;AAE3B,MAAM,yBAAyB,OAAO,WAA8B;AAClE,QAAM,YAAY,QAAQ,IAAI,4BAAc;AAC5C,MAAI,CAAC,WAAW;AACd,UAAM,IAAI,MAAM,mBAAmB,0CAA4B;AAAA,EACjE;AACA,QAAM,SAAS,2BAAa,MAAM,KAAK,MAAM,SAAS,CAAC;AAEvD,MAAI,OAAO,SAAS,QAAQ;AAC1B,UAAM,QAAQ,cAAc,OAAO,IAAI;AAAA,EACzC;AACA,MAAI,OAAO,SAAS,QAAQ;AAC1B,UAAM,QAAQ,cAAc,OAAO,IAAI;AAAA,EACzC;AACF;AAEA,IAAI,6BAAa,SAAS,SAAS;AAEjC,OAAK,uBAAuB,4BAAY;AAC1C;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -18,6 +18,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
20
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
25
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
26
|
mod
|
|
23
27
|
));
|
|
@@ -33,6 +37,7 @@ var import_config = require("./config");
|
|
|
33
37
|
var import_is_child = require("./is-child");
|
|
34
38
|
const SPAWN_SHELL_ENV = {
|
|
35
39
|
FORCE_COLOR: "true"
|
|
40
|
+
// well-known env var used by most shells to enable color output in child processes
|
|
36
41
|
};
|
|
37
42
|
const listenForChildSpawn = (child, logger) => new Promise((resolve, reject) => {
|
|
38
43
|
child.on("spawn", () => {
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/worker/child-wrapper.ts"],
|
|
4
4
|
"sourcesContent": ["import * as childProcess from 'child_process'\nimport type { Logger } from '../logger'\nimport { ENTRY_POINT } from './child-entrypoint'\nimport { CONFIG_ENV_KEY, Config } from './config'\nimport { CHILD_ENV_KEY, CHILD_ENV_VALUE, isChildProcess } from './is-child'\n\nexport type ChildOutput = {\n exitCode: number | null\n signal: NodeJS.Signals | null\n}\n\nconst SPAWN_SHELL_ENV: Record<string, string> = {\n FORCE_COLOR: 'true', // well-known env var used by most shells to enable color output in child processes\n} as const\n\nconst listenForChildSpawn = (child: childProcess.ChildProcess, logger: Logger) =>\n new Promise<void>((resolve, reject) => {\n child.on('spawn', () => {\n logger.debug(`Child process spawned with pid ${child.pid}`)\n resolve()\n })\n child.on('error', (err: Error) => {\n /**\n * The 'error' event is emitted whenever:\n * - The process could not be spawned.\n * - The child process was aborted via the signal option.\n */\n logger.debug(`Child process error: ${err.message}`)\n reject(err)\n })\n })\n\nconst listenForChildExit = (child: childProcess.ChildProcess, logger: Logger) =>\n new Promise<ChildOutput>((resolve, reject) => {\n child.on('disconnect', () => {\n logger.debug('Child process disconnected')\n })\n child.on('close', (exitCode: number | null, signal: NodeJS.Signals | null) => {\n /**\n * this event usually fires after exit unless stdio streams are shared across multiple processes.\n * see https://stackoverflow.com/questions/37522010/difference-between-childprocess-close-exit-events\n */\n logger.debug(`Child process closed with code ${exitCode} and signal ${signal}`)\n })\n child.on('exit', (exitCode: number | null, signal: NodeJS.Signals | null) => {\n logger.debug(`Child process exited with code ${exitCode} and signal ${signal}`)\n resolve({ exitCode, signal })\n })\n child.on('error', (err: Error) => {\n /**\n * The 'error' event is emitted whenever:\n * - The process could not be killed.\n * - The child process was aborted via the signal option.\n */\n logger.debug(`Child process error: ${err.message}`)\n reject(err)\n })\n child.on('message', (message) => {\n logger.debug(`Child process message: ${message}`)\n })\n })\n\n/**\n * Wrapper above child_process.ChildProcess to simplify usage\n */\nexport class ChildProcessWrapper {\n public static async spawn(config: Config, logger: Logger): Promise<ChildProcessWrapper> {\n if (isChildProcess) {\n throw new Error('Cannot spawn child process from child process')\n }\n\n const child = childProcess.fork(ENTRY_POINT, [], {\n stdio: 'inherit',\n env: {\n ...SPAWN_SHELL_ENV,\n [CHILD_ENV_KEY]: CHILD_ENV_VALUE,\n [CONFIG_ENV_KEY]: JSON.stringify(config),\n ...config.env,\n },\n })\n\n const childSpawnPromise = listenForChildSpawn(child, logger)\n const childExitPromise = listenForChildExit(child, logger)\n\n const instance = new ChildProcessWrapper(child, childExitPromise)\n\n childExitPromise.finally(() => {\n instance._exited = true\n })\n\n await childSpawnPromise\n\n return instance\n }\n\n private _exited = false\n private constructor(private _child: childProcess.ChildProcess, private _exitPromise: Promise<ChildOutput>) {}\n\n public async kill(): Promise<ChildOutput> {\n if (this._exited) {\n throw new Error('Child process already exited and cannot be killed')\n }\n this._child.kill()\n const res = await this._exitPromise\n return res\n }\n\n public async listen(): Promise<ChildOutput> {\n if (this._exited) {\n throw new Error('Child process already exited and cannot be listened on')\n }\n const res = await this._exitPromise\n return res\n }\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA8B;AAE9B,8BAA4B;AAC5B,oBAAuC;AACvC,sBAA+D;AAO/D,MAAM,kBAA0C;AAAA,EAC9C,aAAa;AAAA;AACf;AAEA,MAAM,sBAAsB,CAAC,OAAkC,WAC7D,IAAI,QAAc,CAAC,SAAS,WAAW;AACrC,QAAM,GAAG,SAAS,MAAM;AACtB,WAAO,MAAM,kCAAkC,MAAM,KAAK;AAC1D,YAAQ;AAAA,EACV,CAAC;AACD,QAAM,GAAG,SAAS,CAAC,QAAe;AAMhC,WAAO,MAAM,wBAAwB,IAAI,SAAS;AAClD,WAAO,GAAG;AAAA,EACZ,CAAC;AACH,CAAC;AAEH,MAAM,qBAAqB,CAAC,OAAkC,WAC5D,IAAI,QAAqB,CAAC,SAAS,WAAW;AAC5C,QAAM,GAAG,cAAc,MAAM;AAC3B,WAAO,MAAM,4BAA4B;AAAA,EAC3C,CAAC;AACD,QAAM,GAAG,SAAS,CAAC,UAAyB,WAAkC;AAK5E,WAAO,MAAM,kCAAkC,uBAAuB,QAAQ;AAAA,EAChF,CAAC;AACD,QAAM,GAAG,QAAQ,CAAC,UAAyB,WAAkC;AAC3E,WAAO,MAAM,kCAAkC,uBAAuB,QAAQ;AAC9E,YAAQ,EAAE,UA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,EACT;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/worker/is-child.ts"],
|
|
4
4
|
"sourcesContent": ["export const CHILD_ENV_KEY = 'IS_CHILD'\nexport const CHILD_ENV_VALUE = 'true'\n\nexport type MainProcessProps = {\n type: 'main'\n pid: number\n}\nexport type ChildProcessProps = {\n type: 'child'\n sendMessage: (message: string) => void\n pid: number\n}\n\nexport type ProcessProps = MainProcessProps | ChildProcessProps\n\nconst getProcessProps = (): ProcessProps => {\n const type = process.env[CHILD_ENV_KEY] === CHILD_ENV_VALUE ? 'child' : 'main'\n if (type === 'main') {\n return {\n type,\n pid: process.pid,\n }\n }\n\n if (!process.send) {\n throw new Error(`Please do not use variable ${CHILD_ENV_KEY} manually`)\n }\n\n return {\n type,\n sendMessage: process.send,\n pid: process.pid,\n }\n}\n\nexport const processProps = getProcessProps()\nexport const isChildProcess = processProps.type === 'child'\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,gBAAgB;AACtB,MAAM,kBAAkB;AAc/B,MAAM,kBAAkB,MAAoB;AAC1C,QAAM,OAAO,QAAQ,IAAI,
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,gBAAgB;AACtB,MAAM,kBAAkB;AAc/B,MAAM,kBAAkB,MAAoB;AAC1C,QAAM,OAAO,QAAQ,IAAI,aAAa,MAAM,kBAAkB,UAAU;AACxE,MAAI,SAAS,QAAQ;AACnB,WAAO;AAAA,MACL;AAAA,MACA,KAAK,QAAQ;AAAA,IACf;AAAA,EACF;AAEA,MAAI,CAAC,QAAQ,MAAM;AACjB,UAAM,IAAI,MAAM,8BAA8B,wBAAwB;AAAA,EACxE;AAEA,SAAO;AAAA,IACL;AAAA,IACA,aAAa,QAAQ;AAAA,IACrB,KAAK,QAAQ;AAAA,EACf;AACF;AAEO,MAAM,eAAe,gBAAgB;AACrC,MAAM,iBAAiB,aAAa,SAAS;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/worker/worker-state.ts"],
|
|
4
4
|
"sourcesContent": ["import type { ChildProcessWrapper } from './child-wrapper'\n\nexport type WorkerStatus = WorkerState['status']\nexport type WorkerState =\n | { status: 'errored'; thrown: unknown } // only occurs if the event error is emitted https://nodejs.org/api/child_process.html#event-error\n | { status: 'dead'; murdered: boolean }\n | { status: 'killing' }\n | { status: 'reloading' }\n | {\n status: 'live'\n child: ChildProcessWrapper\n }\n\nexport type StateOf<S extends WorkerStatus> = Extract<WorkerState, { status: S }>\nexport type WorkerStateHandler<S extends WorkerStatus> = (state: StateOf<S>) => void\n\nexport class WorkerStateObserver {\n private _state: WorkerState\n private _handlers: {\n [K in WorkerStatus]: WorkerStateHandler<K>[]\n } = {\n dead: [],\n reloading: [],\n live: [],\n killing: [],\n errored: [],\n }\n\n public constructor(initialState: WorkerState) {\n this._state = initialState\n }\n\n public waitFor<S extends WorkerStatus>(status: S): Promise<void> {\n return new Promise<void>((resolve) => {\n const cb = () => {\n this.off(status, cb)\n resolve()\n }\n this.on(status, cb)\n })\n }\n\n public on<S extends WorkerStatus>(status: S, handler: WorkerStateHandler<S>) {\n this._handlers[status].push(handler)\n if (this._state.status === status) {\n handler(this._state as StateOf<S>)\n }\n }\n\n public off<S extends WorkerStatus>(status: S, handler: WorkerStateHandler<S>) {\n const index = this._handlers[status].indexOf(handler)\n this._handlers[status].splice(index, 1)\n }\n\n public get() {\n return this._state\n }\n\n public set(newState: WorkerState) {\n this._state = newState\n const { status } = newState\n for (const handler of this._handlers[status]) {\n const fn = handler as WorkerStateHandler<typeof status>\n fn(newState)\n }\n }\n}\n"],
|
|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