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.
- package/config/tsconfig.json +3 -4
- package/lib/api/git/getChangedFiles.js +19 -2
- package/lib/api/git/getChangedFiles.js.map +3 -3
- package/lib/cli/buildPackage/index.js +2 -2
- package/lib/cli/buildPackage/index.js.map +1 -1
- package/lib/cli/configure/ensureTemplateCompletion.js +5 -3
- package/lib/cli/configure/ensureTemplateCompletion.js.map +2 -2
- package/lib/cli/init/getConfig.d.ts +7 -8
- package/lib/cli/init/getConfig.js +5 -7
- package/lib/cli/init/getConfig.js.map +3 -3
- package/lib/cli/init/prompts.d.ts +5 -5
- package/lib/cli/init/prompts.js +4 -5
- package/lib/cli/init/prompts.js.map +3 -3
- package/lib/cli/init/types.d.ts +13 -109
- package/lib/cli/init/types.js +30 -20
- package/lib/cli/init/types.js.map +2 -2
- package/lib/cli/lint/internalLints/patchRenovateConfig.js +3 -3
- package/lib/cli/lint/internalLints/patchRenovateConfig.js.map +2 -2
- package/lib/cli/migrate/nodeVersion/checks.d.ts +3 -3
- package/lib/cli/migrate/nodeVersion/checks.js +11 -11
- package/lib/cli/migrate/nodeVersion/checks.js.map +2 -2
- package/lib/utils/error.d.ts +3 -23
- package/lib/utils/error.js +18 -8
- package/lib/utils/error.js.map +2 -2
- package/lib/utils/manifest.d.ts +2 -2
- package/lib/utils/manifest.js +4 -4
- package/lib/utils/manifest.js.map +2 -2
- package/lib/utils/packageManager.d.ts +5 -2
- package/lib/utils/packageManager.js +2 -2
- package/lib/utils/packageManager.js.map +2 -2
- package/lib/utils/template.d.ts +9 -38
- package/lib/utils/template.js +22 -10
- package/lib/utils/template.js.map +2 -2
- package/lib/utils/version.d.ts +2 -10
- package/lib/utils/version.js +9 -9
- package/lib/utils/version.js.map +2 -2
- package/package.json +6 -13
- package/template/base/_.prettierrc.js +1 -1
- package/template/base/_eslint.config.js +1 -1
- package/template/base/_pnpm-workspace.yaml +0 -1
- package/template/base/jest.config.ts +3 -17
- package/template/base/tsconfig.json +3 -3
- package/template/express-rest-api/.buildkite/pipeline.yml +2 -1
- package/template/express-rest-api/docker-compose.yml +0 -2
- package/template/express-rest-api/package.json +0 -7
- package/template/express-rest-api/src/app.ts +2 -0
- package/template/express-rest-api/src/framework/logging.ts +1 -1
- package/template/express-rest-api/src/framework/metrics.ts +2 -2
- package/template/express-rest-api/src/listen.ts +2 -0
- package/template/express-rest-api/src/register.ts +1 -0
- package/template/greeter/.buildkite/pipeline.yml +2 -1
- package/template/greeter/docker-compose.yml +0 -2
- package/template/greeter/package.json +1 -8
- package/template/greeter/src/app.ts +2 -2
- package/template/koa-rest-api/.buildkite/pipeline.yml +2 -1
- package/template/koa-rest-api/docker-compose.yml +0 -2
- package/template/koa-rest-api/package.json +4 -11
- package/template/koa-rest-api/src/api/healthCheck.ts +1 -1
- package/template/koa-rest-api/src/api/jobs/getJobs.test.ts +2 -2
- package/template/koa-rest-api/src/api/jobs/getJobs.ts +4 -4
- package/template/koa-rest-api/src/api/jobs/index.ts +2 -2
- package/template/koa-rest-api/src/api/jobs/postJob.test.ts +3 -3
- package/template/koa-rest-api/src/api/jobs/postJob.ts +6 -6
- package/template/koa-rest-api/src/api/smokeTest.ts +2 -2
- package/template/koa-rest-api/src/app.test.ts +2 -2
- package/template/koa-rest-api/src/app.ts +2 -0
- package/template/koa-rest-api/src/framework/logging.ts +1 -1
- package/template/koa-rest-api/src/framework/metrics.ts +2 -2
- package/template/koa-rest-api/src/framework/server.test.ts +5 -5
- package/template/koa-rest-api/src/framework/server.ts +3 -3
- package/template/koa-rest-api/src/framework/validation.test.ts +5 -5
- package/template/koa-rest-api/src/framework/validation.ts +10 -9
- package/template/koa-rest-api/src/listen.ts +2 -0
- package/template/koa-rest-api/src/register.ts +1 -0
- package/template/koa-rest-api/src/storage/jobs.ts +1 -1
- package/template/koa-rest-api/src/testing/metrics.ts +1 -1
- package/template/koa-rest-api/src/testing/server.ts +1 -1
- package/template/koa-rest-api/src/testing/types.ts +2 -2
- package/template/koa-rest-api/src/types/jobs.ts +1 -1
- package/template/lambda-sqs-worker-cdk/.buildkite/pipeline.yml +2 -1
- package/template/lambda-sqs-worker-cdk/docker-compose.yml +0 -2
- package/template/lambda-sqs-worker-cdk/package.json +1 -8
- package/template/lambda-sqs-worker-cdk/src/app.test.ts +5 -5
- package/template/lambda-sqs-worker-cdk/src/app.ts +9 -7
- package/template/lambda-sqs-worker-cdk/src/framework/handler.test.ts +3 -3
- package/template/lambda-sqs-worker-cdk/src/framework/handler.ts +2 -2
- package/template/lambda-sqs-worker-cdk/src/framework/logging.ts +1 -1
- package/template/lambda-sqs-worker-cdk/src/framework/metrics.ts +1 -1
- package/template/lambda-sqs-worker-cdk/src/framework/validation.test.ts +3 -3
- package/template/lambda-sqs-worker-cdk/src/framework/validation.ts +4 -4
- package/template/lambda-sqs-worker-cdk/src/services/jobScorer.test.ts +3 -3
- package/template/lambda-sqs-worker-cdk/src/services/jobScorer.ts +6 -7
- package/template/lambda-sqs-worker-cdk/src/services/pipelineEventSender.test.ts +3 -3
- package/template/lambda-sqs-worker-cdk/src/services/pipelineEventSender.ts +2 -2
- package/template/lambda-sqs-worker-cdk/src/testing/services.ts +2 -2
- package/template/lambda-sqs-worker-cdk/src/testing/types.ts +1 -1
- package/template/lambda-sqs-worker-cdk/src/types/jobScorer.ts +1 -1
- package/template/lambda-sqs-worker-cdk/src/types/pipelineEvents.ts +1 -1
- package/template/lambda-sqs-worker-cdk/tsconfig.json +3 -3
- package/template/oss-npm-package/_package.json +0 -8
- package/template/oss-npm-package/skuba.template.js +1 -1
- package/template/oss-npm-package/tsconfig.json +0 -3
- package/template/private-npm-package/_package.json +0 -7
- package/lib/cli/lint/internalLints/upgrade/patches/11.1.0/index.d.ts +0 -2
- package/lib/cli/lint/internalLints/upgrade/patches/11.1.0/index.js +0 -35
- package/lib/cli/lint/internalLints/upgrade/patches/11.1.0/index.js.map +0 -7
- package/lib/cli/lint/internalLints/upgrade/patches/11.1.0/rewriteSrcImports.d.ts +0 -6
- package/lib/cli/lint/internalLints/upgrade/patches/11.1.0/rewriteSrcImports.js +0 -104
- package/lib/cli/lint/internalLints/upgrade/patches/11.1.0/rewriteSrcImports.js.map +0 -7
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import 'skuba-dive/register';
|
|
@@ -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 '
|
|
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
|
|
2
|
+
import * as z from 'zod/v4';
|
|
3
3
|
|
|
4
|
-
import type { JobInput } from '
|
|
4
|
+
import type { JobInput } from 'src/types/jobs.js';
|
|
5
5
|
|
|
6
6
|
export type IdDescription = z.infer<typeof IdDescriptionSchema>;
|
|
7
7
|
|
|
@@ -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.
|
|
@@ -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": "
|
|
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 '
|
|
5
|
-
import { logger } from '
|
|
6
|
-
import { metricsClient } from '
|
|
7
|
-
import { validateJson } from '
|
|
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 '
|
|
12
|
-
import { sendPipelineEvent } from '
|
|
13
|
-
import { JobPublishedEventSchema } from '
|
|
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 '
|
|
5
|
-
import { logger, loggerContext } from '
|
|
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,
|
|
@@ -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 '
|
|
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
|
|
1
|
+
import type * as z from 'zod/v4';
|
|
2
2
|
|
|
3
|
-
export const validateJson = <
|
|
3
|
+
export const validateJson = <T extends z.ZodType>(
|
|
4
4
|
input: string,
|
|
5
|
-
schema:
|
|
6
|
-
):
|
|
5
|
+
schema: T,
|
|
6
|
+
): z.infer<T> => schema.parse(JSON.parse(input));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { scoringService } from 'src/testing/services.js';
|
|
2
|
+
import { chance, mockJobPublishedEvent } from 'src/testing/types.js';
|
|
2
3
|
|
|
3
|
-
import
|
|
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 '
|
|
4
|
+
} from 'src/mapping/jobScorer.js';
|
|
10
5
|
import {
|
|
11
6
|
type JobScorerInput,
|
|
12
7
|
type JobScorerOutput,
|
|
13
8
|
JobScorerOutputSchema,
|
|
14
|
-
} from '
|
|
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 {
|
|
3
|
+
import { sns } from 'src/testing/services.js';
|
|
4
|
+
import { chance } from 'src/testing/types.js';
|
|
4
5
|
|
|
5
|
-
import {
|
|
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 {
|
|
3
|
+
import { config } from 'src/config.js';
|
|
4
4
|
|
|
5
|
-
import {
|
|
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 '
|
|
7
|
-
import * as jobScorer from '
|
|
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(),
|
|
@@ -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,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,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
|
-
}
|