skuba 12.0.0-subpath-imports-20250710043319 → 12.0.0

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 (109) hide show
  1. package/config/tsconfig.json +3 -4
  2. package/lib/api/git/getChangedFiles.js +19 -2
  3. package/lib/api/git/getChangedFiles.js.map +3 -3
  4. package/lib/cli/buildPackage/index.js +2 -2
  5. package/lib/cli/buildPackage/index.js.map +1 -1
  6. package/lib/cli/configure/ensureTemplateCompletion.js +5 -3
  7. package/lib/cli/configure/ensureTemplateCompletion.js.map +2 -2
  8. package/lib/cli/init/getConfig.d.ts +7 -8
  9. package/lib/cli/init/getConfig.js +5 -7
  10. package/lib/cli/init/getConfig.js.map +3 -3
  11. package/lib/cli/init/prompts.d.ts +5 -5
  12. package/lib/cli/init/prompts.js +4 -5
  13. package/lib/cli/init/prompts.js.map +3 -3
  14. package/lib/cli/init/types.d.ts +13 -109
  15. package/lib/cli/init/types.js +30 -20
  16. package/lib/cli/init/types.js.map +2 -2
  17. package/lib/cli/lint/internalLints/patchRenovateConfig.js +3 -3
  18. package/lib/cli/lint/internalLints/patchRenovateConfig.js.map +2 -2
  19. package/lib/cli/migrate/nodeVersion/checks.d.ts +3 -3
  20. package/lib/cli/migrate/nodeVersion/checks.js +11 -11
  21. package/lib/cli/migrate/nodeVersion/checks.js.map +2 -2
  22. package/lib/utils/error.d.ts +3 -23
  23. package/lib/utils/error.js +18 -8
  24. package/lib/utils/error.js.map +2 -2
  25. package/lib/utils/manifest.d.ts +2 -2
  26. package/lib/utils/manifest.js +4 -4
  27. package/lib/utils/manifest.js.map +2 -2
  28. package/lib/utils/packageManager.d.ts +5 -2
  29. package/lib/utils/packageManager.js +2 -2
  30. package/lib/utils/packageManager.js.map +2 -2
  31. package/lib/utils/template.d.ts +9 -38
  32. package/lib/utils/template.js +22 -10
  33. package/lib/utils/template.js.map +2 -2
  34. package/lib/utils/version.d.ts +2 -10
  35. package/lib/utils/version.js +9 -9
  36. package/lib/utils/version.js.map +2 -2
  37. package/package.json +6 -13
  38. package/template/base/_.prettierrc.js +1 -1
  39. package/template/base/_eslint.config.js +1 -1
  40. package/template/base/_pnpm-workspace.yaml +0 -1
  41. package/template/base/jest.config.ts +3 -17
  42. package/template/base/tsconfig.json +3 -3
  43. package/template/express-rest-api/.buildkite/pipeline.yml +2 -1
  44. package/template/express-rest-api/docker-compose.yml +0 -2
  45. package/template/express-rest-api/package.json +0 -7
  46. package/template/express-rest-api/src/app.ts +2 -0
  47. package/template/express-rest-api/src/framework/logging.ts +1 -1
  48. package/template/express-rest-api/src/framework/metrics.ts +2 -2
  49. package/template/express-rest-api/src/listen.ts +2 -0
  50. package/template/express-rest-api/src/register.ts +1 -0
  51. package/template/greeter/.buildkite/pipeline.yml +2 -1
  52. package/template/greeter/docker-compose.yml +0 -2
  53. package/template/greeter/package.json +1 -8
  54. package/template/greeter/src/app.ts +2 -2
  55. package/template/koa-rest-api/.buildkite/pipeline.yml +2 -1
  56. package/template/koa-rest-api/docker-compose.yml +0 -2
  57. package/template/koa-rest-api/package.json +4 -11
  58. package/template/koa-rest-api/src/api/healthCheck.ts +1 -1
  59. package/template/koa-rest-api/src/api/jobs/getJobs.test.ts +2 -2
  60. package/template/koa-rest-api/src/api/jobs/getJobs.ts +4 -4
  61. package/template/koa-rest-api/src/api/jobs/index.ts +2 -2
  62. package/template/koa-rest-api/src/api/jobs/postJob.test.ts +3 -3
  63. package/template/koa-rest-api/src/api/jobs/postJob.ts +6 -6
  64. package/template/koa-rest-api/src/api/smokeTest.ts +2 -2
  65. package/template/koa-rest-api/src/app.test.ts +2 -2
  66. package/template/koa-rest-api/src/app.ts +2 -0
  67. package/template/koa-rest-api/src/framework/logging.ts +1 -1
  68. package/template/koa-rest-api/src/framework/metrics.ts +2 -2
  69. package/template/koa-rest-api/src/framework/server.test.ts +5 -5
  70. package/template/koa-rest-api/src/framework/server.ts +3 -3
  71. package/template/koa-rest-api/src/framework/validation.test.ts +5 -5
  72. package/template/koa-rest-api/src/framework/validation.ts +10 -9
  73. package/template/koa-rest-api/src/listen.ts +2 -0
  74. package/template/koa-rest-api/src/register.ts +1 -0
  75. package/template/koa-rest-api/src/storage/jobs.ts +1 -1
  76. package/template/koa-rest-api/src/testing/metrics.ts +1 -1
  77. package/template/koa-rest-api/src/testing/server.ts +1 -1
  78. package/template/koa-rest-api/src/testing/types.ts +2 -2
  79. package/template/koa-rest-api/src/types/jobs.ts +1 -1
  80. package/template/lambda-sqs-worker-cdk/.buildkite/pipeline.yml +2 -1
  81. package/template/lambda-sqs-worker-cdk/docker-compose.yml +0 -2
  82. package/template/lambda-sqs-worker-cdk/package.json +1 -8
  83. package/template/lambda-sqs-worker-cdk/src/app.test.ts +5 -5
  84. package/template/lambda-sqs-worker-cdk/src/app.ts +9 -7
  85. package/template/lambda-sqs-worker-cdk/src/framework/handler.test.ts +3 -3
  86. package/template/lambda-sqs-worker-cdk/src/framework/handler.ts +2 -2
  87. package/template/lambda-sqs-worker-cdk/src/framework/logging.ts +1 -1
  88. package/template/lambda-sqs-worker-cdk/src/framework/metrics.ts +1 -1
  89. package/template/lambda-sqs-worker-cdk/src/framework/validation.test.ts +3 -3
  90. package/template/lambda-sqs-worker-cdk/src/framework/validation.ts +4 -4
  91. package/template/lambda-sqs-worker-cdk/src/services/jobScorer.test.ts +3 -3
  92. package/template/lambda-sqs-worker-cdk/src/services/jobScorer.ts +6 -7
  93. package/template/lambda-sqs-worker-cdk/src/services/pipelineEventSender.test.ts +3 -3
  94. package/template/lambda-sqs-worker-cdk/src/services/pipelineEventSender.ts +2 -2
  95. package/template/lambda-sqs-worker-cdk/src/testing/services.ts +2 -2
  96. package/template/lambda-sqs-worker-cdk/src/testing/types.ts +1 -1
  97. package/template/lambda-sqs-worker-cdk/src/types/jobScorer.ts +1 -1
  98. package/template/lambda-sqs-worker-cdk/src/types/pipelineEvents.ts +1 -1
  99. package/template/lambda-sqs-worker-cdk/tsconfig.json +3 -3
  100. package/template/oss-npm-package/_package.json +0 -8
  101. package/template/oss-npm-package/skuba.template.js +1 -1
  102. package/template/oss-npm-package/tsconfig.json +0 -3
  103. package/template/private-npm-package/_package.json +0 -7
  104. package/lib/cli/lint/internalLints/upgrade/patches/11.1.0/index.d.ts +0 -2
  105. package/lib/cli/lint/internalLints/upgrade/patches/11.1.0/index.js +0 -35
  106. package/lib/cli/lint/internalLints/upgrade/patches/11.1.0/index.js.map +0 -7
  107. package/lib/cli/lint/internalLints/upgrade/patches/11.1.0/rewriteSrcImports.d.ts +0 -6
  108. package/lib/cli/lint/internalLints/upgrade/patches/11.1.0/rewriteSrcImports.js +0 -104
  109. package/lib/cli/lint/internalLints/upgrade/patches/11.1.0/rewriteSrcImports.js.map +0 -7
@@ -1,3 +1,5 @@
1
+ import './register.js';
2
+
1
3
  import app from './app.js';
2
4
  import { config } from './config.js';
3
5
  import { logger } from './framework/logging.js';
@@ -0,0 +1 @@
1
+ import 'skuba-dive/register';
@@ -1,6 +1,6 @@
1
1
  import { randomUUID } from 'crypto';
2
2
 
3
- import type { Job, JobInput } from '#src/types/jobs.js';
3
+ import type { Job, JobInput } from 'src/types/jobs.js';
4
4
 
5
5
  const jobStore: Record<string, Job> = {};
6
6
 
@@ -1,4 +1,4 @@
1
- import * as metrics from '#src/framework/metrics.js';
1
+ import * as metrics from 'src/framework/metrics.js';
2
2
 
3
3
  function assertDefined<T>(value: T | undefined): asserts value is T {
4
4
  expect(value).toBeDefined();
@@ -2,7 +2,7 @@ import type Router from '@koa/router';
2
2
  import type Koa from 'koa';
3
3
  import request from 'supertest';
4
4
 
5
- import { createApp } from '#src/framework/server.js';
5
+ import { createApp } from 'src/framework/server.js';
6
6
 
7
7
  /**
8
8
  * Create a new SuperTest agent from a Koa application.
@@ -1,7 +1,7 @@
1
1
  import { Chance } from 'chance';
2
- import { z } from 'zod/v4';
2
+ import * as z from 'zod/v4';
3
3
 
4
- import type { JobInput } from '#src/types/jobs.js';
4
+ import type { JobInput } from 'src/types/jobs.js';
5
5
 
6
6
  export type IdDescription = z.infer<typeof IdDescriptionSchema>;
7
7
 
@@ -1,4 +1,4 @@
1
- import { z } from 'zod/v4';
1
+ import * as z from 'zod/v4';
2
2
 
3
3
  export interface Job {
4
4
  id: string;
@@ -25,10 +25,11 @@ configs:
25
25
  - *docker-ecr-cache
26
26
  - docker-compose#v5.10.0:
27
27
  dependencies: false
28
- run: app
29
28
  environment:
30
29
  - GITHUB_API_TOKEN
30
+ mount-buildkite-agent: true
31
31
  propagate-environment: true
32
+ run: app
32
33
  retry:
33
34
  manual:
34
35
  # Only use this if you need to roll back a deployment ASAP.
@@ -4,8 +4,6 @@ services:
4
4
  init: true
5
5
  volumes:
6
6
  - ./:/workdir
7
- # Mount agent for Buildkite annotations.
8
- - /usr/bin/buildkite-agent:/usr/bin/buildkite-agent
9
7
  # Mount cached dependencies.
10
8
  - /workdir/node_modules
11
9
  - /workdir/lib/node_modules
@@ -2,13 +2,6 @@
2
2
  "name": "@seek/<%- serviceName %>",
3
3
  "private": true,
4
4
  "license": "UNLICENSED",
5
- "imports": {
6
- "#src/*": {
7
- "types": "./src/*",
8
- "import": "./lib/*",
9
- "require": "./lib/*"
10
- }
11
- },
12
5
  "scripts": {
13
6
  "deploy": "cdk deploy appStack --require-approval never",
14
7
  "deploy:hotswap": "pnpm --silent run deploy --hotswap",
@@ -44,7 +37,7 @@
44
37
  "constructs": "^10.0.17",
45
38
  "datadog-cdk-constructs-v2": "^2.0.0",
46
39
  "pino-pretty": "^13.0.0",
47
- "skuba": "12.0.0-subpath-imports-20250710043319"
40
+ "skuba": "*"
48
41
  },
49
42
  "packageManager": "pnpm@10.12.4",
50
43
  "engines": {
@@ -1,13 +1,13 @@
1
1
  import { PublishCommand } from '@aws-sdk/client-sns';
2
2
 
3
+ import { metricsClient } from 'src/framework/metrics.js';
4
+ import { createCtx, createSqsEvent } from 'src/testing/handler.js';
5
+ import { scoringService, sns } from 'src/testing/services.js';
6
+ import { chance, mockJobPublishedEvent } from 'src/testing/types.js';
7
+
3
8
  import * as app from './app.js';
4
9
  import { stdoutMock } from './framework/logging.js';
5
10
 
6
- import { metricsClient } from '#src/framework/metrics.js';
7
- import { createCtx, createSqsEvent } from '#src/testing/handler.js';
8
- import { scoringService, sns } from '#src/testing/services.js';
9
- import { chance, mockJobPublishedEvent } from '#src/testing/types.js';
10
-
11
11
  describe('app', () => {
12
12
  it('exports a handler', () => expect(app).toHaveProperty('handler'));
13
13
  });
@@ -1,16 +1,18 @@
1
+ import 'skuba-dive/register';
2
+
1
3
  import { isLambdaHook } from '@seek/aws-codedeploy-hooks';
2
4
  import type { SQSEvent } from 'aws-lambda';
3
5
 
4
- import { createHandler } from '#src/framework/handler.js';
5
- import { logger } from '#src/framework/logging.js';
6
- import { metricsClient } from '#src/framework/metrics.js';
7
- import { validateJson } from '#src/framework/validation.js';
6
+ import { createHandler } from 'src/framework/handler.js';
7
+ import { logger } from 'src/framework/logging.js';
8
+ import { metricsClient } from 'src/framework/metrics.js';
9
+ import { validateJson } from 'src/framework/validation.js';
8
10
  import {
9
11
  scoreJobPublishedEvent,
10
12
  scoringService,
11
- } from '#src/services/jobScorer.js';
12
- import { sendPipelineEvent } from '#src/services/pipelineEventSender.js';
13
- import { JobPublishedEventSchema } from '#src/types/pipelineEvents.js';
13
+ } from 'src/services/jobScorer.js';
14
+ import { sendPipelineEvent } from 'src/services/pipelineEventSender.js';
15
+ import { JobPublishedEventSchema } from 'src/types/pipelineEvents.js';
14
16
 
15
17
  /**
16
18
  * Tests connectivity to ensure appropriate access and network configuration.
@@ -1,9 +1,9 @@
1
+ import { createCtx } from 'src/testing/handler.js';
2
+ import { chance } from 'src/testing/types.js';
3
+
1
4
  import { createHandler } from './handler.js';
2
5
  import { logger, stdoutMock } from './logging.js';
3
6
 
4
- import { createCtx } from '#src/testing/handler.js';
5
- import { chance } from '#src/testing/types.js';
6
-
7
7
  describe('createHandler', () => {
8
8
  const ctx = createCtx();
9
9
  const input = chance.paragraph();
@@ -1,8 +1,8 @@
1
1
  import type { Context as LambdaContext } from 'aws-lambda';
2
2
  import { datadog } from 'datadog-lambda-js';
3
3
 
4
- import { config } from '#src/config.js';
5
- import { logger, loggerContext } from '#src/framework/logging.js';
4
+ import { config } from 'src/config.js';
5
+ import { logger, loggerContext } from 'src/framework/logging.js';
6
6
 
7
7
  type Handler<Event, Output> = (
8
8
  event: Event,
@@ -2,7 +2,7 @@ import { AsyncLocalStorage } from 'async_hooks';
2
2
 
3
3
  import createLogger, { createDestination } from '@seek/logger';
4
4
 
5
- import { config } from '#src/config.js';
5
+ import { config } from 'src/config.js';
6
6
 
7
7
  interface LoggerContext {
8
8
  awsRequestId: string;
@@ -1,6 +1,6 @@
1
1
  import { sendDistributionMetric } from 'datadog-lambda-js';
2
2
 
3
- import { config } from '#src/config.js';
3
+ import { config } from 'src/config.js';
4
4
 
5
5
  const prefix = `${config.name}.`;
6
6
 
@@ -1,10 +1,10 @@
1
- import { validateJson } from './validation.js';
2
-
3
1
  import {
4
2
  IdDescriptionSchema,
5
3
  chance,
6
4
  mockIdDescription,
7
- } from '#src/testing/types.js';
5
+ } from 'src/testing/types.js';
6
+
7
+ import { validateJson } from './validation.js';
8
8
 
9
9
  describe('validateJson', () => {
10
10
  const idDescription = mockIdDescription();
@@ -1,6 +1,6 @@
1
- import type { z } from 'zod/v4';
1
+ import type * as z from 'zod/v4';
2
2
 
3
- export const validateJson = <Output, Input>(
3
+ export const validateJson = <T extends z.ZodType>(
4
4
  input: string,
5
- schema: z.ZodSchema<Output, Input>,
6
- ): Output => schema.parse(JSON.parse(input));
5
+ schema: T,
6
+ ): z.infer<T> => schema.parse(JSON.parse(input));
@@ -1,7 +1,7 @@
1
- import * as jobScorer from './jobScorer.js';
1
+ import { scoringService } from 'src/testing/services.js';
2
+ import { chance, mockJobPublishedEvent } from 'src/testing/types.js';
2
3
 
3
- import { scoringService } from '#src/testing/services.js';
4
- import { chance, mockJobPublishedEvent } from '#src/testing/types.js';
4
+ import * as jobScorer from './jobScorer.js';
5
5
 
6
6
  describe('scoreJobPublishedEvent', () => {
7
7
  beforeAll(scoringService.spy);
@@ -1,17 +1,16 @@
1
- import type {
2
- JobPublishedEvent,
3
- JobScoredEvent,
4
- } from 'src/types/pipelineEvents.js';
5
-
6
1
  import {
7
2
  jobPublishedEventToScorerInput,
8
3
  jobScorerOutputToScoredEvent,
9
- } from '#src/mapping/jobScorer.js';
4
+ } from 'src/mapping/jobScorer.js';
10
5
  import {
11
6
  type JobScorerInput,
12
7
  type JobScorerOutput,
13
8
  JobScorerOutputSchema,
14
- } from '#src/types/jobScorer.js';
9
+ } from 'src/types/jobScorer.js';
10
+ import type {
11
+ JobPublishedEvent,
12
+ JobScoredEvent,
13
+ } from 'src/types/pipelineEvents.js';
15
14
 
16
15
  /* istanbul ignore next: simulation of an external service */
17
16
  export const scoringService = {
@@ -1,9 +1,9 @@
1
1
  import { PublishCommand } from '@aws-sdk/client-sns';
2
2
 
3
- import { sendPipelineEvent } from './pipelineEventSender.js';
3
+ import { sns } from 'src/testing/services.js';
4
+ import { chance } from 'src/testing/types.js';
4
5
 
5
- import { sns } from '#src/testing/services.js';
6
- import { chance } from '#src/testing/types.js';
6
+ import { sendPipelineEvent } from './pipelineEventSender.js';
7
7
 
8
8
  describe('sendPipelineEvent', () => {
9
9
  afterEach(() => {
@@ -1,8 +1,8 @@
1
1
  import { PublishCommand } from '@aws-sdk/client-sns';
2
2
 
3
- import { sns } from './aws.js';
3
+ import { config } from 'src/config.js';
4
4
 
5
- import { config } from '#src/config.js';
5
+ import { sns } from './aws.js';
6
6
 
7
7
  export const sendPipelineEvent = async (
8
8
  event: unknown,
@@ -3,8 +3,8 @@ import 'aws-sdk-client-mock-jest';
3
3
  import { PublishCommand } from '@aws-sdk/client-sns';
4
4
  import { mockClient } from 'aws-sdk-client-mock';
5
5
 
6
- import { sns as snsClient } from '#src/services/aws.js';
7
- import * as jobScorer from '#src/services/jobScorer.js';
6
+ import { sns as snsClient } from 'src/services/aws.js';
7
+ import * as jobScorer from 'src/services/jobScorer.js';
8
8
 
9
9
  export const scoringService = {
10
10
  request: jest.fn(),
@@ -1,5 +1,5 @@
1
1
  import { Chance } from 'chance';
2
- import { z } from 'zod/v4';
2
+ import * as z from 'zod/v4';
3
3
 
4
4
  import type { JobPublishedEvent } from 'src/types/pipelineEvents.js';
5
5
 
@@ -1,4 +1,4 @@
1
- import { z } from 'zod/v4';
1
+ import * as z from 'zod/v4';
2
2
 
3
3
  export type JobScorerInput = z.infer<typeof JobScorerInputSchema>;
4
4
 
@@ -1,4 +1,4 @@
1
- import { z } from 'zod/v4';
1
+ import * as z from 'zod/v4';
2
2
 
3
3
  export type JobPublishedEvent = z.infer<typeof JobPublishedEventSchema>;
4
4
 
@@ -2,10 +2,10 @@
2
2
  "compilerOptions": {
3
3
  "baseUrl": ".",
4
4
  "lib": ["ES2024"],
5
- "moduleResolution": "node16",
6
- "module": "node18",
7
5
  "outDir": "lib",
8
- "rootDir": ".",
6
+ "paths": {
7
+ "src": ["src"]
8
+ },
9
9
  "target": "ES2024"
10
10
  },
11
11
  "exclude": ["lib*/**/*"],
@@ -2,14 +2,6 @@
2
2
  "name": "<%- moduleName %>",
3
3
  "version": "0.0.0-semantically-released",
4
4
  "description": "<%- description %>",
5
- "type": "module",
6
- "imports": {
7
- "#src/*": {
8
- "types": "./src/*",
9
- "import": "./lib/*",
10
- "require": "./lib/*"
11
- }
12
- },
13
5
  "repository": {
14
6
  "type": "git",
15
7
  "url": "git+ssh://git@github.com/<%- orgName %>/<%- repoName %>.git"
@@ -2,7 +2,7 @@
2
2
  * Run `skuba configure` to finish templating and remove this file.
3
3
  */
4
4
 
5
- export default {
5
+ module.exports = {
6
6
  entryPoint: 'src/index.ts',
7
7
  fields: [
8
8
  {
@@ -1,11 +1,8 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "lib": ["ES2022"],
4
- "module": "node18",
5
- "moduleResolution": "node16",
6
4
  "outDir": "lib",
7
5
  "removeComments": false,
8
- "rootDir": ".",
9
6
  "target": "ES2022"
10
7
  },
11
8
  "exclude": ["lib*/**/*"],
@@ -2,13 +2,6 @@
2
2
  "name": "<%- moduleName %>",
3
3
  "version": "0.0.0-semantically-released",
4
4
  "description": "<%- description %>",
5
- "imports": {
6
- "#src/*": {
7
- "types": "./src/*",
8
- "import": "./lib/*",
9
- "require": "./lib/*"
10
- }
11
- },
12
5
  "repository": {
13
6
  "type": "git",
14
7
  "url": "git+ssh://git@github.com/<%- orgName %>/<%- repoName %>.git"
@@ -1,2 +0,0 @@
1
- import type { Patches } from '../../index.js';
2
- export declare const patches: Patches;
@@ -1,35 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var __exports = {};
20
- __export(__exports, {
21
- patches: () => patches
22
- });
23
- module.exports = __toCommonJS(__exports);
24
- var import_rewriteSrcImports = require("./rewriteSrcImports.js");
25
- const patches = [
26
- {
27
- apply: import_rewriteSrcImports.rewriteSrcImports,
28
- description: "Rewrite all 'src' imports to be '#src'"
29
- }
30
- ];
31
- // Annotate the CommonJS export names for ESM import in node:
32
- 0 && (module.exports = {
33
- patches
34
- });
35
- //# sourceMappingURL=index.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../../../src/cli/lint/internalLints/upgrade/patches/11.1.0/index.ts"],
4
- "sourcesContent": ["import type { Patches } from '../../index.js';\n\nimport { rewriteSrcImports } from './rewriteSrcImports.js';\n\nexport const patches: Patches = [\n {\n apply: rewriteSrcImports,\n description: \"Rewrite all 'src' imports to be '#src'\",\n },\n];\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,+BAAkC;AAE3B,MAAM,UAAmB;AAAA,EAC9B;AAAA,IACE,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AACF;",
6
- "names": []
7
- }
@@ -1,6 +0,0 @@
1
- import type { PatchFunction } from '../../index.js';
2
- export declare const hasSkubaDiveRegisterImportRegex: RegExp;
3
- export declare const hasSrcImportRegex: RegExp;
4
- export declare const replaceSrcImport: (contents: string) => string;
5
- export declare const tryRewriteSrcImports: PatchFunction;
6
- export declare const rewriteSrcImports: PatchFunction;
@@ -1,104 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
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.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var rewriteSrcImports_exports = {};
30
- __export(rewriteSrcImports_exports, {
31
- hasSkubaDiveRegisterImportRegex: () => hasSkubaDiveRegisterImportRegex,
32
- hasSrcImportRegex: () => hasSrcImportRegex,
33
- replaceSrcImport: () => replaceSrcImport,
34
- rewriteSrcImports: () => rewriteSrcImports,
35
- tryRewriteSrcImports: () => tryRewriteSrcImports
36
- });
37
- module.exports = __toCommonJS(rewriteSrcImports_exports);
38
- var import_util = require("util");
39
- var import_fast_glob = require("fast-glob");
40
- var import_fs_extra = __toESM(require("fs-extra"));
41
- var import_logging = require("../../../../../../utils/logging.js");
42
- const fetchFiles = async (files) => Promise.all(
43
- files.map(async (file) => {
44
- const contents = await import_fs_extra.default.promises.readFile(file, "utf8");
45
- return {
46
- file,
47
- contents
48
- };
49
- })
50
- );
51
- const hasSkubaDiveRegisterImportRegex = /import\s+['"](?:skuba-dive\/register|\.\.?\/.*?register)(?:\.js)?['"];?\s*/gm;
52
- const hasSrcImportRegex = /import\s+(?:type\s+\{[^}]*\}|\{[^}]*\}|\*\s+as\s+\w+|\w+(?:\s*,\s*\{[^}]*\})?)\s+from\s+['"]src\/[^'"]*['"]/gm;
53
- const replaceSrcImport = (contents) => contents.replace(
54
- hasSrcImportRegex,
55
- (match) => match.replace(/(['"])src\//g, "$1#src/")
56
- );
57
- const removeSkubaDiveRegisterImport = (contents) => contents.replace(hasSkubaDiveRegisterImportRegex, "");
58
- const replaceAllImports = (contents) => removeSkubaDiveRegisterImport(replaceSrcImport(contents));
59
- const tryRewriteSrcImports = async ({
60
- mode
61
- }) => {
62
- const tsFileNames = await (0, import_fast_glob.glob)(["**/*.ts", "**/*.test.ts"]);
63
- if (!tsFileNames.length) {
64
- return {
65
- result: "skip",
66
- reason: "no .ts or test.ts files found"
67
- };
68
- }
69
- const tsFiles = await fetchFiles(tsFileNames);
70
- const mapped = tsFiles.map(({ file, contents }) => ({
71
- file,
72
- before: contents,
73
- after: replaceAllImports(contents)
74
- }));
75
- if (mode === "lint") {
76
- return {
77
- result: "apply"
78
- };
79
- }
80
- await Promise.all(
81
- mapped.map(async ({ file, after }) => {
82
- await import_fs_extra.default.promises.writeFile(file, after);
83
- })
84
- );
85
- return { result: "apply" };
86
- };
87
- const rewriteSrcImports = async (config) => {
88
- try {
89
- return await tryRewriteSrcImports(config);
90
- } catch (err) {
91
- import_logging.log.warn("Failed to rewrite src imports to #src");
92
- import_logging.log.subtle((0, import_util.inspect)(err));
93
- return { result: "skip", reason: "due to an error" };
94
- }
95
- };
96
- // Annotate the CommonJS export names for ESM import in node:
97
- 0 && (module.exports = {
98
- hasSkubaDiveRegisterImportRegex,
99
- hasSrcImportRegex,
100
- replaceSrcImport,
101
- rewriteSrcImports,
102
- tryRewriteSrcImports
103
- });
104
- //# sourceMappingURL=rewriteSrcImports.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../../../src/cli/lint/internalLints/upgrade/patches/11.1.0/rewriteSrcImports.ts"],
4
- "sourcesContent": ["import { inspect } from 'util';\n\nimport { glob } from 'fast-glob';\nimport fs from 'fs-extra';\n\nimport { log } from '../../../../../../utils/logging.js';\nimport type { PatchFunction, PatchReturnType } from '../../index.js';\n\nconst fetchFiles = async (files: string[]) =>\n Promise.all(\n files.map(async (file) => {\n const contents = await fs.promises.readFile(file, 'utf8');\n\n return {\n file,\n contents,\n };\n }),\n );\n\nexport const hasSkubaDiveRegisterImportRegex =\n /import\\s+['\"](?:skuba-dive\\/register|\\.\\.?\\/.*?register)(?:\\.js)?['\"];?\\s*/gm;\n\nexport const hasSrcImportRegex =\n /import\\s+(?:type\\s+\\{[^}]*\\}|\\{[^}]*\\}|\\*\\s+as\\s+\\w+|\\w+(?:\\s*,\\s*\\{[^}]*\\})?)\\s+from\\s+['\"]src\\/[^'\"]*['\"]/gm;\n\nexport const replaceSrcImport = (contents: string) =>\n contents.replace(hasSrcImportRegex, (match) =>\n match.replace(/(['\"])src\\//g, '$1#src/'),\n );\n\nconst removeSkubaDiveRegisterImport = (contents: string) =>\n contents.replace(hasSkubaDiveRegisterImportRegex, '');\n\nconst replaceAllImports = (contents: string) =>\n removeSkubaDiveRegisterImport(replaceSrcImport(contents));\n\nexport const tryRewriteSrcImports: PatchFunction = async ({\n mode,\n}): Promise<PatchReturnType> => {\n const tsFileNames = await glob(['**/*.ts', '**/*.test.ts']);\n\n if (!tsFileNames.length) {\n return {\n result: 'skip',\n reason: 'no .ts or test.ts files found',\n };\n }\n\n const tsFiles = await fetchFiles(tsFileNames);\n\n const mapped = tsFiles.map(({ file, contents }) => ({\n file,\n before: contents,\n after: replaceAllImports(contents),\n }));\n\n if (mode === 'lint') {\n return {\n result: 'apply',\n };\n }\n\n await Promise.all(\n mapped.map(async ({ file, after }) => {\n await fs.promises.writeFile(file, after);\n }),\n );\n\n return { result: 'apply' };\n};\n\nexport const rewriteSrcImports: PatchFunction = async (config) => {\n try {\n return await tryRewriteSrcImports(config);\n } catch (err) {\n log.warn('Failed to rewrite src imports to #src');\n log.subtle(inspect(err));\n return { result: 'skip', reason: 'due to an error' };\n }\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAwB;AAExB,uBAAqB;AACrB,sBAAe;AAEf,qBAAoB;AAGpB,MAAM,aAAa,OAAO,UACxB,QAAQ;AAAA,EACN,MAAM,IAAI,OAAO,SAAS;AACxB,UAAM,WAAW,MAAM,gBAAAA,QAAG,SAAS,SAAS,MAAM,MAAM;AAExD,WAAO;AAAA,MACL;AAAA,MACA;AAAA,IACF;AAAA,EACF,CAAC;AACH;AAEK,MAAM,kCACX;AAEK,MAAM,oBACX;AAEK,MAAM,mBAAmB,CAAC,aAC/B,SAAS;AAAA,EAAQ;AAAA,EAAmB,CAAC,UACnC,MAAM,QAAQ,gBAAgB,SAAS;AACzC;AAEF,MAAM,gCAAgC,CAAC,aACrC,SAAS,QAAQ,iCAAiC,EAAE;AAEtD,MAAM,oBAAoB,CAAC,aACzB,8BAA8B,iBAAiB,QAAQ,CAAC;AAEnD,MAAM,uBAAsC,OAAO;AAAA,EACxD;AACF,MAAgC;AAC9B,QAAM,cAAc,UAAM,uBAAK,CAAC,WAAW,cAAc,CAAC;AAE1D,MAAI,CAAC,YAAY,QAAQ;AACvB,WAAO;AAAA,MACL,QAAQ;AAAA,MACR,QAAQ;AAAA,IACV;AAAA,EACF;AAEA,QAAM,UAAU,MAAM,WAAW,WAAW;AAE5C,QAAM,SAAS,QAAQ,IAAI,CAAC,EAAE,MAAM,SAAS,OAAO;AAAA,IAClD;AAAA,IACA,QAAQ;AAAA,IACR,OAAO,kBAAkB,QAAQ;AAAA,EACnC,EAAE;AAEF,MAAI,SAAS,QAAQ;AACnB,WAAO;AAAA,MACL,QAAQ;AAAA,IACV;AAAA,EACF;AAEA,QAAM,QAAQ;AAAA,IACZ,OAAO,IAAI,OAAO,EAAE,MAAM,MAAM,MAAM;AACpC,YAAM,gBAAAA,QAAG,SAAS,UAAU,MAAM,KAAK;AAAA,IACzC,CAAC;AAAA,EACH;AAEA,SAAO,EAAE,QAAQ,QAAQ;AAC3B;AAEO,MAAM,oBAAmC,OAAO,WAAW;AAChE,MAAI;AACF,WAAO,MAAM,qBAAqB,MAAM;AAAA,EAC1C,SAAS,KAAK;AACZ,uBAAI,KAAK,uCAAuC;AAChD,uBAAI,WAAO,qBAAQ,GAAG,CAAC;AACvB,WAAO,EAAE,QAAQ,QAAQ,QAAQ,kBAAkB;AAAA,EACrD;AACF;",
6
- "names": ["fs"]
7
- }