@mrgrain/cdk-esbuild 2.0.0-alpha.1 → 2.0.0-rc.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.
@@ -1,22 +1,21 @@
1
- import { readFileSync } from 'fs';
2
- import { ESLint } from 'eslint';
3
1
  import {
4
2
  AwsCdkConstructLibrary,
5
3
  JsonFile,
6
4
  NodePackageManager,
7
- TextFile,
5
+ release,
8
6
  vscode,
9
7
  } from 'projen';
8
+ import { SourceFile } from 'ts-morph';
9
+ import { TypeScriptSourceFile } from './projenrc/TypeScriptSourceFile';
10
10
 
11
11
  const project = new AwsCdkConstructLibrary({
12
12
  projenrcTs: true,
13
13
  projenrcTsOptions: {
14
- filename: '.projenrc.mjs',
14
+ filename: '.projenrc.ts',
15
15
  },
16
16
  eslintOptions: {
17
17
  lintProjenRc: false,
18
- fileExtensions: ['.ts', '.tsx', '.mjs'],
19
- dirs: ['src', '.projenrc.mjs'],
18
+ dirs: ['src', 'projenrc', '.projenrc.ts'],
20
19
  },
21
20
 
22
21
  // Project info
@@ -48,36 +47,36 @@ const project = new AwsCdkConstructLibrary({
48
47
  npmDistTag: 'next',
49
48
  defaultReleaseBranch: 'next',
50
49
  majorVersion: 2,
51
- prerelease: 'alpha',
52
- releaseEveryCommit: false,
50
+ prerelease: 'rc',
51
+ releaseTrigger: release.ReleaseTrigger.manual(),
53
52
  catalog: {
54
53
  twitter: '@mrgrain',
55
54
  },
56
55
  workflowContainerImage: 'jsii/superchain:1-buster-slim-node14',
57
- // release: undefined /* Add release management to this project. */,
58
56
 
59
57
  // Dependencies
60
58
  cdkVersion: '1.99.0',
61
59
  cdkDependencies: [
62
- '@aws-cdk/core',
63
60
  '@aws-cdk/aws-lambda',
64
61
  '@aws-cdk/aws-s3',
65
62
  '@aws-cdk/aws-s3-assets',
66
63
  '@aws-cdk/aws-s3-deployment',
67
64
  '@aws-cdk/aws-synthetics',
65
+ '@aws-cdk/core',
68
66
  ],
69
67
  cdkTestDependencies: [
70
- '@aws-cdk/core',
71
- '@aws-cdk/aws-lambda',
72
68
  '@aws-cdk/assert',
69
+ '@aws-cdk/aws-lambda',
73
70
  '@aws-cdk/aws-s3',
74
71
  '@aws-cdk/aws-s3-assets',
75
72
  '@aws-cdk/aws-s3-deployment',
76
73
  '@aws-cdk/aws-synthetics',
74
+ '@aws-cdk/core',
77
75
  ],
78
76
  devDeps: [
79
77
  '@types/eslint',
80
78
  'esbuild@^0.13.0',
79
+ 'ts-morph',
81
80
  ],
82
81
 
83
82
  // Ignore files
@@ -88,6 +87,7 @@ const project = new AwsCdkConstructLibrary({
88
87
  'cdk.out',
89
88
  '.cdk.staging',
90
89
  'examples/template',
90
+ '!/.github/workflows/manual-release.yml',
91
91
  ],
92
92
  npmignore: [
93
93
  '.npmrc',
@@ -105,37 +105,21 @@ const project = new AwsCdkConstructLibrary({
105
105
  });
106
106
 
107
107
  const packageJson = project.tryFindObjectFile('package.json');
108
- packageJson.addOverride('optionalDependencies', {
108
+ packageJson?.addOverride('optionalDependencies', {
109
109
  esbuild: '^0.13.0',
110
110
  });
111
- packageJson.addOverride('jest.testPathIgnorePatterns.1', '/examples/');
111
+ packageJson?.addOverride('jest.testPathIgnorePatterns.1', '/examples/');
112
112
 
113
113
  const eslintRc = project.tryFindObjectFile('.eslintrc.json');
114
- eslintRc.addOverride('parserOptions.extraFileExtensions', ['.mjs']);
115
- eslintRc.addOverride('ignorePatterns', [
114
+ eslintRc?.addOverride('ignorePatterns', [
116
115
  '*.js',
117
116
  '*.d.ts',
118
117
  'node_modules/',
119
118
  '*.generated.ts',
120
119
  'coverage',
121
- '!.projenrc.mjs',
120
+ '!.projenrc.ts',
122
121
  ]);
123
122
 
124
- const linter = new ESLint({ fix: true });
125
- const esbuildTypes = (
126
- await linter.lintText(
127
- readFileSync('node_modules/esbuild/lib/main.d.ts').toString(),
128
- {
129
- filePath: 'src/esbuild-types-raw.ts',
130
- },
131
- )
132
- ).pop().output;
133
-
134
- new TextFile(project, 'src/esbuild-types-raw.ts', {
135
- editGitignore: false,
136
- lines: [esbuildTypes],
137
- });
138
-
139
123
  new JsonFile(project, '.vscode/extensions.json', {
140
124
  readonly: false,
141
125
  marker: false,
@@ -171,4 +155,26 @@ new vscode.VsCode(project).launchConfiguration.addConfiguration({
171
155
  args: ['--runInBand', '--watchAll=false'],
172
156
  });
173
157
 
158
+
159
+ new TypeScriptSourceFile(project, 'src/esbuild-types.ts', {
160
+ source: 'node_modules/esbuild/lib/main.d.ts',
161
+ editGitignore: false,
162
+ transformer: (esbuildTypes: SourceFile) => {
163
+ const readonlyInterface = (name: string) => {
164
+ esbuildTypes.getInterface(name)?.getProperties().forEach(property => property.setIsReadonly(true));
165
+ };
166
+
167
+ const removeFromInterface = (name: string, properties: string[]) => {
168
+ const interfaceDeclaration = esbuildTypes.getInterface(name);
169
+
170
+ properties.forEach(property => interfaceDeclaration?.getProperty(property)?.remove());
171
+ };
172
+
173
+
174
+ ['CommonOptions', 'BuildOptions', 'TransformOptions'].forEach(readonlyInterface);
175
+ removeFromInterface('BuildOptions', ['entryPoints', 'stdin', 'plugins', 'watch']);
176
+ esbuildTypes.getInterface('TransformOptions')?.getProperty('tsconfigRaw')?.setType('string');
177
+ },
178
+ });
179
+
174
180
  project.synth();