@langri-sha/projen-project 0.8.1 → 0.10.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/CHANGELOG.json +275 -1
- package/CHANGELOG.md +64 -2
- package/lib/index.d.ts +60 -14
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +220 -54
- package/lib/index.js.map +1 -1
- package/lib/lib/index.d.ts +1 -0
- package/lib/lib/index.d.ts.map +1 -1
- package/lib/lib/index.js +1 -0
- package/lib/lib/index.js.map +1 -1
- package/lib/lib/node-package.d.ts +19 -0
- package/lib/lib/node-package.d.ts.map +1 -0
- package/lib/lib/node-package.js +43 -0
- package/lib/lib/node-package.js.map +1 -0
- package/lib/lib/projenrc.d.ts.map +1 -1
- package/lib/lib/projenrc.js +4 -0
- package/lib/lib/projenrc.js.map +1 -1
- package/license +4 -14
- package/package.json +27 -15
- package/readme +1 -1
- package/src/index.ts +371 -79
- package/src/lib/index.ts +1 -0
- package/src/lib/node-package.ts +50 -0
- package/src/lib/projenrc.ts +7 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import * as fs from 'node:fs'
|
|
2
|
+
import { Project, javascript } from 'projen'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Options for configuring Node.js packages.
|
|
6
|
+
*/
|
|
7
|
+
export interface NodePackageOptions extends javascript.NodePackageOptions {
|
|
8
|
+
peerDependenciesMeta?: Record<string, { optional?: boolean }>
|
|
9
|
+
type?: 'commonjs' | 'module'
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Custom Node.js package manager that preserves package.
|
|
14
|
+
*/
|
|
15
|
+
export class NodePackage extends javascript.NodePackage {
|
|
16
|
+
constructor(project: Project, options?: NodePackageOptions) {
|
|
17
|
+
super(project, options)
|
|
18
|
+
|
|
19
|
+
this.addVersion(this.#getPackageJson()?.version ?? '0.0.0')
|
|
20
|
+
|
|
21
|
+
if (options?.type) {
|
|
22
|
+
this.addField('type', options.type)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (options?.peerDependenciesMeta) {
|
|
26
|
+
this.addField('peerDependenciesMeta', options.peerDependenciesMeta)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Reset, so we can run `pnpx projen` on CI after Renovate upgrades.
|
|
30
|
+
this.project.tasks
|
|
31
|
+
.tryFind('install:ci')
|
|
32
|
+
?.reset(this.project.tasks.tryFind('install')?.steps[0]?.exec)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
#getPackageJson() {
|
|
36
|
+
try {
|
|
37
|
+
return JSON.parse(fs.readFileSync(this.file.absolutePath, 'utf-8'))
|
|
38
|
+
} catch (_) {
|
|
39
|
+
return undefined
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
override postSynthesize(): void {
|
|
44
|
+
if (this.project.parent) {
|
|
45
|
+
return
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
super.postSynthesize()
|
|
49
|
+
}
|
|
50
|
+
}
|
package/src/lib/projenrc.ts
CHANGED
|
@@ -17,7 +17,14 @@ export class ProjenrcFile extends BaseProjenrcFile {
|
|
|
17
17
|
) {
|
|
18
18
|
super(project)
|
|
19
19
|
|
|
20
|
+
if (project.parent) {
|
|
21
|
+
this.filePath = ProjenrcFile.of(project.parent)?.filePath ?? filename
|
|
22
|
+
|
|
23
|
+
return
|
|
24
|
+
}
|
|
25
|
+
|
|
20
26
|
this.filePath = filename
|
|
27
|
+
|
|
21
28
|
this.project.defaultTask?.exec(
|
|
22
29
|
`node --loader ts-node/esm/transpile-only ${filename}`,
|
|
23
30
|
)
|