@mrgrain/cdk-esbuild 4.0.0-alpha.4 → 4.0.0-alpha.7
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/.jsii +381 -220
- package/.projenrc.ts +5 -0
- package/API.md +312 -166
- package/README.md +10 -0
- package/lib/asset.d.ts +1 -1
- package/lib/asset.js +10 -7
- package/lib/bundler.d.ts +8 -0
- package/lib/bundler.js +7 -2
- package/lib/code.d.ts +10 -19
- package/lib/code.js +20 -11
- package/lib/esbuild-wrapper.js +16 -3
- package/lib/index.d.ts +4 -4
- package/lib/index.js +3 -1
- package/lib/inline-code.js +4 -4
- package/lib/source.js +2 -2
- package/node_modules/isexe/.npmignore +2 -0
- package/node_modules/isexe/LICENSE +15 -0
- package/node_modules/isexe/README.md +51 -0
- package/node_modules/isexe/index.js +57 -0
- package/node_modules/isexe/mode.js +41 -0
- package/node_modules/isexe/package.json +35 -0
- package/node_modules/isexe/test/basic.js +221 -0
- package/node_modules/isexe/windows.js +42 -0
- package/node_modules/which/CHANGELOG.md +166 -0
- package/node_modules/which/LICENSE +15 -0
- package/node_modules/which/README.md +54 -0
- package/node_modules/which/bin/node-which +52 -0
- package/node_modules/which/package.json +47 -0
- package/node_modules/which/which.js +125 -0
- package/package.json +8 -1
- package/projenrc/TypeScriptSourceFile.ts +0 -50
- package/projenrc/release.ts +0 -13
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
const isWindows = process.platform === 'win32' ||
|
|
2
|
+
process.env.OSTYPE === 'cygwin' ||
|
|
3
|
+
process.env.OSTYPE === 'msys'
|
|
4
|
+
|
|
5
|
+
const path = require('path')
|
|
6
|
+
const COLON = isWindows ? ';' : ':'
|
|
7
|
+
const isexe = require('isexe')
|
|
8
|
+
|
|
9
|
+
const getNotFoundError = (cmd) =>
|
|
10
|
+
Object.assign(new Error(`not found: ${cmd}`), { code: 'ENOENT' })
|
|
11
|
+
|
|
12
|
+
const getPathInfo = (cmd, opt) => {
|
|
13
|
+
const colon = opt.colon || COLON
|
|
14
|
+
|
|
15
|
+
// If it has a slash, then we don't bother searching the pathenv.
|
|
16
|
+
// just check the file itself, and that's it.
|
|
17
|
+
const pathEnv = cmd.match(/\//) || isWindows && cmd.match(/\\/) ? ['']
|
|
18
|
+
: (
|
|
19
|
+
[
|
|
20
|
+
// windows always checks the cwd first
|
|
21
|
+
...(isWindows ? [process.cwd()] : []),
|
|
22
|
+
...(opt.path || process.env.PATH ||
|
|
23
|
+
/* istanbul ignore next: very unusual */ '').split(colon),
|
|
24
|
+
]
|
|
25
|
+
)
|
|
26
|
+
const pathExtExe = isWindows
|
|
27
|
+
? opt.pathExt || process.env.PATHEXT || '.EXE;.CMD;.BAT;.COM'
|
|
28
|
+
: ''
|
|
29
|
+
const pathExt = isWindows ? pathExtExe.split(colon) : ['']
|
|
30
|
+
|
|
31
|
+
if (isWindows) {
|
|
32
|
+
if (cmd.indexOf('.') !== -1 && pathExt[0] !== '')
|
|
33
|
+
pathExt.unshift('')
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
pathEnv,
|
|
38
|
+
pathExt,
|
|
39
|
+
pathExtExe,
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const which = (cmd, opt, cb) => {
|
|
44
|
+
if (typeof opt === 'function') {
|
|
45
|
+
cb = opt
|
|
46
|
+
opt = {}
|
|
47
|
+
}
|
|
48
|
+
if (!opt)
|
|
49
|
+
opt = {}
|
|
50
|
+
|
|
51
|
+
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt)
|
|
52
|
+
const found = []
|
|
53
|
+
|
|
54
|
+
const step = i => new Promise((resolve, reject) => {
|
|
55
|
+
if (i === pathEnv.length)
|
|
56
|
+
return opt.all && found.length ? resolve(found)
|
|
57
|
+
: reject(getNotFoundError(cmd))
|
|
58
|
+
|
|
59
|
+
const ppRaw = pathEnv[i]
|
|
60
|
+
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw
|
|
61
|
+
|
|
62
|
+
const pCmd = path.join(pathPart, cmd)
|
|
63
|
+
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd
|
|
64
|
+
: pCmd
|
|
65
|
+
|
|
66
|
+
resolve(subStep(p, i, 0))
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
const subStep = (p, i, ii) => new Promise((resolve, reject) => {
|
|
70
|
+
if (ii === pathExt.length)
|
|
71
|
+
return resolve(step(i + 1))
|
|
72
|
+
const ext = pathExt[ii]
|
|
73
|
+
isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
|
|
74
|
+
if (!er && is) {
|
|
75
|
+
if (opt.all)
|
|
76
|
+
found.push(p + ext)
|
|
77
|
+
else
|
|
78
|
+
return resolve(p + ext)
|
|
79
|
+
}
|
|
80
|
+
return resolve(subStep(p, i, ii + 1))
|
|
81
|
+
})
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
return cb ? step(0).then(res => cb(null, res), cb) : step(0)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const whichSync = (cmd, opt) => {
|
|
88
|
+
opt = opt || {}
|
|
89
|
+
|
|
90
|
+
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt)
|
|
91
|
+
const found = []
|
|
92
|
+
|
|
93
|
+
for (let i = 0; i < pathEnv.length; i ++) {
|
|
94
|
+
const ppRaw = pathEnv[i]
|
|
95
|
+
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw
|
|
96
|
+
|
|
97
|
+
const pCmd = path.join(pathPart, cmd)
|
|
98
|
+
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd
|
|
99
|
+
: pCmd
|
|
100
|
+
|
|
101
|
+
for (let j = 0; j < pathExt.length; j ++) {
|
|
102
|
+
const cur = p + pathExt[j]
|
|
103
|
+
try {
|
|
104
|
+
const is = isexe.sync(cur, { pathExt: pathExtExe })
|
|
105
|
+
if (is) {
|
|
106
|
+
if (opt.all)
|
|
107
|
+
found.push(cur)
|
|
108
|
+
else
|
|
109
|
+
return cur
|
|
110
|
+
}
|
|
111
|
+
} catch (ex) {}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (opt.all && found.length)
|
|
116
|
+
return found
|
|
117
|
+
|
|
118
|
+
if (opt.nothrow)
|
|
119
|
+
return null
|
|
120
|
+
|
|
121
|
+
throw getNotFoundError(cmd)
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
module.exports = which
|
|
125
|
+
which.sync = whichSync
|
package/package.json
CHANGED
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
"@types/eslint": "^7.29.0",
|
|
43
43
|
"@types/jest": "^27.5.2",
|
|
44
44
|
"@types/node": "^14",
|
|
45
|
+
"@types/which": "^2.0.1",
|
|
45
46
|
"@typescript-eslint/eslint-plugin": "^5",
|
|
46
47
|
"@typescript-eslint/parser": "^5",
|
|
47
48
|
"aws-cdk-lib": "2.0.0",
|
|
@@ -71,6 +72,12 @@
|
|
|
71
72
|
"aws-cdk-lib": "^2.0.0",
|
|
72
73
|
"constructs": "^10.0.5"
|
|
73
74
|
},
|
|
75
|
+
"dependencies": {
|
|
76
|
+
"which": "^2.0.2"
|
|
77
|
+
},
|
|
78
|
+
"bundledDependencies": [
|
|
79
|
+
"which"
|
|
80
|
+
],
|
|
74
81
|
"keywords": [
|
|
75
82
|
"aws-cdk",
|
|
76
83
|
"bundler",
|
|
@@ -85,7 +92,7 @@
|
|
|
85
92
|
"main": "lib/index.js",
|
|
86
93
|
"license": "MIT",
|
|
87
94
|
"homepage": "https://github.com/mrgrain/cdk-esbuild",
|
|
88
|
-
"version": "4.0.0-alpha.
|
|
95
|
+
"version": "4.0.0-alpha.7",
|
|
89
96
|
"jest": {
|
|
90
97
|
"testPathIgnorePatterns": [
|
|
91
98
|
"/node_modules/",
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { FileBase, FileBaseOptions, Project as ProjenProject } from 'projen';
|
|
2
|
-
import { execCapture } from 'projen/lib/util';
|
|
3
|
-
import { Project, SourceFile } from 'ts-morph';
|
|
4
|
-
|
|
5
|
-
interface TypeScriptSourceFileOptions extends Omit<FileBaseOptions, 'readonly'> {
|
|
6
|
-
source: string;
|
|
7
|
-
transformer?: (sourcefile: SourceFile) => void;
|
|
8
|
-
format?: boolean;
|
|
9
|
-
marker?: boolean;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export class TypeScriptSourceFile extends FileBase {
|
|
13
|
-
public readonly options: TypeScriptSourceFileOptions;
|
|
14
|
-
|
|
15
|
-
constructor(project: ProjenProject, filePath: string, options: TypeScriptSourceFileOptions) {
|
|
16
|
-
super(project, filePath, { ...options, readonly: false });
|
|
17
|
-
|
|
18
|
-
this.options = {
|
|
19
|
-
format: true,
|
|
20
|
-
marker: true,
|
|
21
|
-
...options,
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
protected synthesizeContent(): string {
|
|
26
|
-
const tsProject = new Project({
|
|
27
|
-
tsConfigFilePath: 'tsconfig.json',
|
|
28
|
-
skipAddingFilesFromTsConfig: true,
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
const sourceFile = tsProject.addSourceFileAtPath(this.options.source);
|
|
32
|
-
|
|
33
|
-
if (this.options.transformer) {
|
|
34
|
-
this.options.transformer(sourceFile);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return [
|
|
38
|
-
...(this.options.marker ? [`// ${this.marker}`] : []),
|
|
39
|
-
'',
|
|
40
|
-
sourceFile.getFullText(),
|
|
41
|
-
].join('\n');
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
public postSynthesize() {
|
|
45
|
-
super.postSynthesize();
|
|
46
|
-
|
|
47
|
-
const outdir = this.project.outdir;
|
|
48
|
-
execCapture(`npx eslint --ext .ts --fix ${this.absolutePath}`, { cwd: outdir });
|
|
49
|
-
}
|
|
50
|
-
}
|
package/projenrc/release.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export function tagOnNpm(packageName: string, tags: string[]) {
|
|
2
|
-
return {
|
|
3
|
-
name: 'Update tags',
|
|
4
|
-
run: [
|
|
5
|
-
'version=`cat dist/version.txt`',
|
|
6
|
-
'echo $version',
|
|
7
|
-
].concat(tags.map(tag => `npm dist-tag add ${packageName}@$version ${tag}`)).join('\n'),
|
|
8
|
-
env: {
|
|
9
|
-
NPM_REGISTRY: 'registry.npmjs.org',
|
|
10
|
-
NPM_TOKEN: '${{ secrets.NPM_TOKEN }}',
|
|
11
|
-
},
|
|
12
|
-
};
|
|
13
|
-
}
|