projen 0.76.5 → 0.76.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 +46 -46
- package/README.md +38 -33
- package/lib/awscdk/auto-discover.js +5 -5
- package/lib/awscdk/awscdk-app-java.js +1 -1
- package/lib/awscdk/awscdk-app-py.js +1 -1
- package/lib/awscdk/awscdk-app-ts.js +1 -1
- package/lib/awscdk/awscdk-construct.js +2 -2
- package/lib/awscdk/awscdk-deps-java.js +1 -1
- package/lib/awscdk/awscdk-deps-js.js +1 -1
- package/lib/awscdk/awscdk-deps-py.js +1 -1
- package/lib/awscdk/awscdk-deps.js +1 -1
- package/lib/awscdk/cdk-config.js +1 -1
- package/lib/awscdk/cdk-tasks.js +1 -1
- package/lib/awscdk/integration-test.js +1 -1
- package/lib/awscdk/lambda-extension.js +1 -1
- package/lib/awscdk/lambda-function.js +2 -2
- package/lib/build/build-workflow.js +1 -1
- package/lib/cdk/auto-discover-base.js +2 -2
- package/lib/cdk/construct-lib.js +1 -1
- package/lib/cdk/integration-test-base.js +1 -1
- package/lib/cdk/jsii-docgen.js +1 -1
- package/lib/cdk/jsii-project.js +1 -1
- package/lib/cdk8s/auto-discover.js +2 -2
- package/lib/cdk8s/cdk8s-app-py.js +1 -1
- package/lib/cdk8s/cdk8s-app-ts.js +1 -1
- package/lib/cdk8s/cdk8s-construct.js +1 -1
- package/lib/cdk8s/cdk8s-deps-py.js +1 -1
- package/lib/cdk8s/cdk8s-deps.js +1 -1
- package/lib/cdk8s/integration-test.js +1 -1
- package/lib/cdktf/cdktf-construct.js +1 -1
- package/lib/circleci/circleci.js +1 -1
- package/lib/component.js +1 -1
- package/lib/dependencies.js +1 -1
- package/lib/dev-env.js +1 -1
- package/lib/docker-compose/docker-compose-service.js +1 -1
- package/lib/docker-compose/docker-compose.js +1 -1
- package/lib/file.js +3 -3
- package/lib/gitattributes.js +1 -1
- package/lib/github/actions-provider.js +1 -1
- package/lib/github/auto-approve.js +1 -1
- package/lib/github/auto-merge.js +1 -1
- package/lib/github/dependabot.js +1 -1
- package/lib/github/github-credentials.js +1 -1
- package/lib/github/github-project.js +1 -1
- package/lib/github/github.js +1 -1
- package/lib/github/mergify.js +1 -1
- package/lib/github/pr-template.js +1 -1
- package/lib/github/pull-request-lint.js +1 -1
- package/lib/github/stale.js +1 -1
- package/lib/github/task-workflow.js +1 -1
- package/lib/github/workflow-actions.js +1 -1
- package/lib/github/workflow-jobs.js +1 -1
- package/lib/github/workflows.js +1 -1
- package/lib/gitlab/configuration.js +1 -1
- package/lib/gitlab/gitlab-configuration.js +1 -1
- package/lib/gitlab/nested-configuration.js +1 -1
- package/lib/gitpod.js +1 -1
- package/lib/ignore-file.js +1 -1
- package/lib/ini.js +1 -1
- package/lib/java/java-project.js +1 -1
- package/lib/java/junit.js +1 -1
- package/lib/java/maven-compile.js +1 -1
- package/lib/java/maven-packaging.js +1 -1
- package/lib/java/maven-sample.js +1 -1
- package/lib/java/pom.js +1 -1
- package/lib/java/projenrc.js +1 -1
- package/lib/javascript/bundler.js +1 -1
- package/lib/javascript/eslint.js +1 -1
- package/lib/javascript/jest.js +4 -4
- package/lib/javascript/node-package.js +1 -1
- package/lib/javascript/node-project.d.ts +2 -1
- package/lib/javascript/node-project.js +11 -6
- package/lib/javascript/npm-config.js +1 -1
- package/lib/javascript/prettier.js +1 -1
- package/lib/javascript/projenrc.js +1 -1
- package/lib/javascript/typescript-config.js +2 -2
- package/lib/javascript/upgrade-dependencies.d.ts +1 -1
- package/lib/javascript/upgrade-dependencies.js +3 -3
- package/lib/json-patch.js +1 -1
- package/lib/json.js +1 -1
- package/lib/license.js +1 -1
- package/lib/logger.js +1 -1
- package/lib/makefile.js +1 -1
- package/lib/object-file.js +1 -1
- package/lib/project-build.js +1 -1
- package/lib/project.d.ts +4 -4
- package/lib/project.js +6 -6
- package/lib/projects.js +1 -1
- package/lib/projenrc-json.js +2 -2
- package/lib/projenrc.js +1 -1
- package/lib/python/pip.js +1 -1
- package/lib/python/poetry.js +2 -2
- package/lib/python/projenrc.js +1 -1
- package/lib/python/pytest-sample.js +1 -1
- package/lib/python/pytest.js +1 -1
- package/lib/python/python-project.js +1 -1
- package/lib/python/python-sample.js +1 -1
- package/lib/python/requirements-file.js +1 -1
- package/lib/python/setuppy.js +1 -1
- package/lib/python/setuptools.js +1 -1
- package/lib/python/venv.js +1 -1
- package/lib/readme.js +1 -1
- package/lib/release/publisher.js +1 -1
- package/lib/release/release-trigger.js +1 -1
- package/lib/release/release.js +1 -1
- package/lib/renovatebot.js +1 -1
- package/lib/sample-file.js +2 -2
- package/lib/semver.js +1 -1
- package/lib/source-code.js +1 -1
- package/lib/task-runtime.js +1 -1
- package/lib/task.js +1 -1
- package/lib/tasks.js +1 -1
- package/lib/testing.js +1 -1
- package/lib/textfile.js +1 -1
- package/lib/toml.js +1 -1
- package/lib/typescript/projenrc-ts.js +1 -1
- package/lib/typescript/projenrc.js +1 -1
- package/lib/typescript/typescript-typedoc.js +1 -1
- package/lib/typescript/typescript.js +3 -3
- package/lib/util.d.ts +1 -0
- package/lib/util.js +2 -1
- package/lib/version.js +2 -2
- package/lib/vscode/devcontainer.js +1 -1
- package/lib/vscode/extensions.js +1 -1
- package/lib/vscode/launch-config.js +1 -1
- package/lib/vscode/settings.js +1 -1
- package/lib/vscode/vscode.js +1 -1
- package/lib/web/next.js +3 -3
- package/lib/web/postcss.js +1 -1
- package/lib/web/react.js +4 -4
- package/lib/web/tailwind.js +1 -1
- package/lib/xmlfile.js +1 -1
- package/lib/yaml.js +1 -1
- package/package.json +1 -1
- package/.prettierignore +0 -1
- package/.prettierrc.json +0 -3
- package/docs/CNAME +0 -1
- package/docs/README.md +0 -28
- package/docs/api/API.md +0 -21296
- package/docs/awscdk-apps.md +0 -18
- package/docs/awscdk-construct.md +0 -195
- package/docs/awscdk.md +0 -377
- package/docs/build.md +0 -55
- package/docs/bundling.md +0 -30
- package/docs/cdk8s.md +0 -39
- package/docs/circleci.md +0 -87
- package/docs/components.md +0 -21
- package/docs/deps.md +0 -62
- package/docs/eject.md +0 -30
- package/docs/escape-hatches.md +0 -113
- package/docs/github.md +0 -155
- package/docs/gitlab.md +0 -67
- package/docs/java.md +0 -213
- package/docs/node.md +0 -150
- package/docs/programmatic-api.md +0 -56
- package/docs/publisher.md +0 -148
- package/docs/python.md +0 -169
- package/docs/releases.md +0 -191
- package/docs/subproject.md +0 -37
- package/docs/tasks.md +0 -211
- package/docs/typescript.md +0 -119
- package/logo/projen.svg +0 -211
- package/rfcs/github-project-settings.md +0 -95
- package/rfcs/project-creation-prompt.md +0 -95
- package/version.json +0 -3
package/docs/cdk8s.md
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
# CDK8s Projects
|
|
2
|
-
|
|
3
|
-
We support two types of projects for Kubernetes powered by the CDK8s:
|
|
4
|
-
**apps** and **libraries**. Apps represent complete Kubernetes applications
|
|
5
|
-
while libraries vend constructs which can be consumed by other libraries or
|
|
6
|
-
by apps. Libraries are published to public or internal package managers (npm,
|
|
7
|
-
PyPI, Maven, NuGet, etc) while apps are deployed into Kubernetes clusters.
|
|
8
|
-
|
|
9
|
-
This section describes features that are available in both CDK8s libraries and
|
|
10
|
-
applications.
|
|
11
|
-
|
|
12
|
-
## Integration Snapshot Tests
|
|
13
|
-
|
|
14
|
-
Files in the `test/` tree with the `.integ.ts` suffix are recognized as
|
|
15
|
-
*integration snapshot tests*.
|
|
16
|
-
|
|
17
|
-
Each test is a simple CDK8s app which exercises certain construct(s) within
|
|
18
|
-
the project. A test is considered passing if the app can be successfully
|
|
19
|
-
deployed.
|
|
20
|
-
|
|
21
|
-
To create/update the snapshot, developers are expected to execute the task
|
|
22
|
-
`integ:NAME:deploy` with a kubectl configuration for their personal development
|
|
23
|
-
environment, such as K3s, Microk8s, Kind, Rancher Desktop, or otherwise. This
|
|
24
|
-
task will deploy the test app by applying it with kubectl. Upon successful
|
|
25
|
-
deployment (i.e. the test passed), the snapshot will be captured and stored
|
|
26
|
-
under a directory called `xxx.integ.snapshot` next to the test entrypoint. This
|
|
27
|
-
directory should be committed to the repository.
|
|
28
|
-
|
|
29
|
-
During builds (either local or within a workflow), the task `integ:NAME:assert`
|
|
30
|
-
will be executed. This task synthesizes the test app and compares the output to
|
|
31
|
-
the captured snapshot. The build will fail if the output differs.
|
|
32
|
-
|
|
33
|
-
For each integration test, the following set of tasks are created:
|
|
34
|
-
|
|
35
|
-
|Task|Description|
|
|
36
|
-
|----|-----------|
|
|
37
|
-
|`integ:NAME:deploy`|Deploys the test app and updates the snapshot.|
|
|
38
|
-
|`integ:NAME:assert`|Synthesizes the test app and compares it with the snapshot (this is the task that runs during build)|
|
|
39
|
-
|`integ:NAME:snapshot`|Synthesizes the test app and updates the snapshot (not recommended to use because it bypasses deployment).|
|
package/docs/circleci.md
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
# CircleCi
|
|
2
|
-
|
|
3
|
-
CircleCi uses `.circleci/config.yml` to specify the configuration of a pipeline.
|
|
4
|
-
Configuration reference can be found [here](https://circleci.com/docs/2.0/configuration-reference).
|
|
5
|
-
|
|
6
|
-
Initial configuration can be created through options of [CircleCiProps](src/circleci/model.ts).
|
|
7
|
-
Additionally, you can add workflows or orbs later to your pipeline.
|
|
8
|
-
For full configuration example checkout [Circleci Tests](test/cirlceci/circleci.test.ts)
|
|
9
|
-
|
|
10
|
-
```js
|
|
11
|
-
const { circleci, typescript } = require('projen');
|
|
12
|
-
|
|
13
|
-
const project = new typescript.TypeScriptProject({
|
|
14
|
-
name: 'projen-example',
|
|
15
|
-
defaultReleaseBranch: 'main',
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
const c = new circleci.Circleci(project, {
|
|
19
|
-
orbs: {
|
|
20
|
-
node: 'circleci/node@5.0.1',
|
|
21
|
-
},
|
|
22
|
-
jobs: [
|
|
23
|
-
{
|
|
24
|
-
identifier: "release",
|
|
25
|
-
resourceClass: circleci.ResourceClass.SMALL,
|
|
26
|
-
docker: [{
|
|
27
|
-
image: "cimg/node:lts"
|
|
28
|
-
}],
|
|
29
|
-
steps: [
|
|
30
|
-
"checkout",
|
|
31
|
-
{run: {command: "npx semantic-release"}},
|
|
32
|
-
]
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
identifier: 'integ-test',
|
|
36
|
-
docker: [{
|
|
37
|
-
image: "cimg/golang:lts"
|
|
38
|
-
}],
|
|
39
|
-
steps: [
|
|
40
|
-
"checkout",
|
|
41
|
-
{
|
|
42
|
-
"go/test": {
|
|
43
|
-
covermode: "atomic",
|
|
44
|
-
failfast: true,
|
|
45
|
-
race: true,
|
|
46
|
-
},
|
|
47
|
-
}
|
|
48
|
-
]
|
|
49
|
-
}
|
|
50
|
-
],
|
|
51
|
-
workflows: [
|
|
52
|
-
{
|
|
53
|
-
identifier: 'build',
|
|
54
|
-
jobs: [
|
|
55
|
-
{
|
|
56
|
-
identifier: 'node/test',
|
|
57
|
-
orbParameters: {
|
|
58
|
-
"test-results-for": "jest"
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
identifier: "release",
|
|
63
|
-
filters: circleci.FilterMainBranchOnly,
|
|
64
|
-
}
|
|
65
|
-
],
|
|
66
|
-
},
|
|
67
|
-
],
|
|
68
|
-
});
|
|
69
|
-
c.addOrb("go", "circleci/go@1.7.1")
|
|
70
|
-
c.addWorkflow({
|
|
71
|
-
identifier: 'nightly',
|
|
72
|
-
triggers: [
|
|
73
|
-
{
|
|
74
|
-
schedule: {
|
|
75
|
-
cron: '0 0 * * *',
|
|
76
|
-
filters: circleci.FilterMainBranchOnly,
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
],
|
|
80
|
-
jobs: [
|
|
81
|
-
{
|
|
82
|
-
identifier: 'integ-test'
|
|
83
|
-
}
|
|
84
|
-
]
|
|
85
|
-
})
|
|
86
|
-
project.synth();
|
|
87
|
-
```
|
package/docs/components.md
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
# Components
|
|
2
|
-
|
|
3
|
-
Components are building blocks that can be composed together into projects. They
|
|
4
|
-
represent a self-contained project feature.
|
|
5
|
-
|
|
6
|
-
When a component is created, it is associated with a specific project:
|
|
7
|
-
|
|
8
|
-
```ts
|
|
9
|
-
const p = new Project(...);
|
|
10
|
-
|
|
11
|
-
new MyComponent(p);
|
|
12
|
-
new YourComponent(p, { /* options */ });
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
Projects can be queried for which components have been added to them:
|
|
16
|
-
|
|
17
|
-
```ts
|
|
18
|
-
for (const c of p.components) {
|
|
19
|
-
// do something with `component`
|
|
20
|
-
}
|
|
21
|
-
```
|
package/docs/deps.md
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
# Dependencies
|
|
2
|
-
|
|
3
|
-
Dependencies are an intrinsic part of every software project.
|
|
4
|
-
|
|
5
|
-
The `Dependencies` component is responsible to track the list of dependencies a
|
|
6
|
-
project has, and then used by project types as the model for rendering
|
|
7
|
-
project-specific dependency manifests such as the dependencies section
|
|
8
|
-
`package.json` files.
|
|
9
|
-
|
|
10
|
-
To add a dependency you can use a project-type specific API such as
|
|
11
|
-
`nodeProject.addDeps()` or use the generic API of `project.deps`:
|
|
12
|
-
|
|
13
|
-
```ts
|
|
14
|
-
project.deps.addDependency(dep, type);
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
By default, `npx projen` will automatically install dependencies in your
|
|
18
|
-
project if they are not already installed.
|
|
19
|
-
|
|
20
|
-
## Semantic Requirements
|
|
21
|
-
|
|
22
|
-
The first argument (`dep`) is a string in the form `MODULE[@VERSION]` where
|
|
23
|
-
`MODULE` is the package-manager specific name of the dependency (i.e. for node
|
|
24
|
-
projects, this is the npm module name) and `VERSION` is an optional [semantic
|
|
25
|
-
version] requirement (e.g. `@^7`).
|
|
26
|
-
|
|
27
|
-
## Dependency Types
|
|
28
|
-
|
|
29
|
-
The second argument (`type`) defines the dependency type and is one of:
|
|
30
|
-
|
|
31
|
-
- `DependencyType.RUNTIME`: The dependency is required for the program/library during runtime.
|
|
32
|
-
- `DependencyType.PEER`: The dependency is required at runtime but only a single
|
|
33
|
-
copy of the module must exist in the dependency closure of the consumer. In
|
|
34
|
-
most package managers (PyPI, NuGet, Maven) there is no difference between
|
|
35
|
-
runtime and peer dependencies (since all dependencies are installed as peers),
|
|
36
|
-
but in npm, this is an important distinction. Prior to npm@7, peer
|
|
37
|
-
dependencies must be installed explicitly by consumers.
|
|
38
|
-
- `DependencyType.BUNDLED`: A runtime dependency that is bundled and shipped
|
|
39
|
-
with the module, so consumers are not required to install it.
|
|
40
|
-
- `DependencyType.BUILD`: The dependency is required to run the `build` task.
|
|
41
|
-
- `DependencyType.TEST`: The dependency is required to run the `test` task.
|
|
42
|
-
- `DependencyType.DEVENV`: The dependency is required for development (e.g. IDE plugins).
|
|
43
|
-
|
|
44
|
-
[semantic version]: https://semver.org
|
|
45
|
-
|
|
46
|
-
## Overriding Dependency Specifications
|
|
47
|
-
|
|
48
|
-
If a dependency is added multiple times, the last specification will prevail.
|
|
49
|
-
This allows you to override dependency specs added by projects or components.
|
|
50
|
-
|
|
51
|
-
For example, if you wish to change the version of the TypeScript compiler used
|
|
52
|
-
in TypeScript projects:
|
|
53
|
-
|
|
54
|
-
```ts
|
|
55
|
-
const { typescript } = require('projen');
|
|
56
|
-
|
|
57
|
-
const project = new typescript.TypeScriptProject({
|
|
58
|
-
/* ... */
|
|
59
|
-
});
|
|
60
|
-
project.addDevDeps('typescript@^5');
|
|
61
|
-
project.synth();
|
|
62
|
-
```
|
package/docs/eject.md
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
# Ejecting
|
|
2
|
-
|
|
3
|
-
To stop from using projen to manage your project configuration,
|
|
4
|
-
you can `eject` at any time and continue to manage your configuration manually.
|
|
5
|
-
|
|
6
|
-
Running `projen eject` will do the following:
|
|
7
|
-
|
|
8
|
-
- uninstall projen as a project dependency
|
|
9
|
-
- change projen-managed files from readonly to user-writeable
|
|
10
|
-
- remove "Generated by projen" markers from projen-generated files
|
|
11
|
-
- remove projen metadata files
|
|
12
|
-
- remove the projen synthesis step from the `build` task
|
|
13
|
-
- remove the `default` and `eject` tasks
|
|
14
|
-
- "backup" projenrc files to `.projenrc.xyz.bak`
|
|
15
|
-
- a separate task runner file is added to the root directory (see Tasks below
|
|
16
|
-
for more information)
|
|
17
|
-
|
|
18
|
-
You do not need to ever use `eject`, but the option is available if the means of
|
|
19
|
-
customization provided by projen are no longer suitable your project.
|
|
20
|
-
|
|
21
|
-
## Tasks
|
|
22
|
-
|
|
23
|
-
A script will be added to your project so that you can continue using existing
|
|
24
|
-
tasks by running `scripts/run-task <task>` in your command line (or running `npm
|
|
25
|
-
run <task>` in node-based projects) if you so choose. You must retain the
|
|
26
|
-
`tasks.json` file found in the `.projen/` folder to use the task runner.
|
|
27
|
-
|
|
28
|
-
> Note: it is possible some tasks may not work after projen is ejected due to
|
|
29
|
-
the use of projen "builtin" steps. See
|
|
30
|
-
https://github.com/projen/projen/issues/1563 for more information.
|
package/docs/escape-hatches.md
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
# Escape hatches
|
|
2
|
-
|
|
3
|
-
It's possible projen doesn't have the right high-level or low-level APIs that
|
|
4
|
-
you need for managing your project configuration. If you think there's an API
|
|
5
|
-
that would be useful, first consider checking on GitHub to see if anyone else
|
|
6
|
-
has the same problem, or consider opening an issue! But in the meantime, there
|
|
7
|
-
are ways you can bypass projen's regular APIs to add special configuration code.
|
|
8
|
-
|
|
9
|
-
## Object File Patches
|
|
10
|
-
|
|
11
|
-
For any "object"-based files, such as JSON, YAML, TOML, or XML, you can
|
|
12
|
-
patch its contents using the JSON Patch standard:
|
|
13
|
-
|
|
14
|
-
```ts
|
|
15
|
-
// Get the ObjectFile
|
|
16
|
-
const packageJson = project.tryFindObjectFile('package.json');
|
|
17
|
-
|
|
18
|
-
// Adds a value to an object or inserts it into an array at a giving position
|
|
19
|
-
packageJson.patch(JsonPatch.add('/author/name', 'A. Mused'));
|
|
20
|
-
packageJson.patch(JsonPatch.add('/keywords/1', 'web'));
|
|
21
|
-
// Use the - character to insert at the end of an array
|
|
22
|
-
packageJson.patch(JsonPatch.add('/keywords/-', 'productivity'));
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
// Removes a value from an object or array
|
|
26
|
-
packageJson.patch(JsonPatch.remove('/author'));
|
|
27
|
-
packageJson.patch(JsonPatch.remove('/keywords/1'));
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
// Copy a value from one location in the document to another
|
|
31
|
-
packageJson.patch(JsonPatch.copy('/homepage', '/bugs/url'));
|
|
32
|
-
|
|
33
|
-
// Replace a value. This is equivalent to a remove, followed by an add.
|
|
34
|
-
packageJson.patch(JsonPatch.replace('/keywords/1', 'iot'));
|
|
35
|
-
|
|
36
|
-
// Move a value. This is equivalent to a copy, followed by a remove.
|
|
37
|
-
packageJson.patch(JsonPatch.move('/homepage', '/bugs/url'));
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
`ObjectFile.patch()` accepts multiple patch instructions at a time, and each set is considered an atomic operation.
|
|
41
|
-
Order matters here: For example you can successfully `add('/foo', 'bar')` and then `remove('/foo')`.
|
|
42
|
-
However reversing the order will fail if `/for` does not exists.
|
|
43
|
-
|
|
44
|
-
### Asserting values
|
|
45
|
-
|
|
46
|
-
Another feature is asserting values.
|
|
47
|
-
This can be used to conditionally set values, or to assert a file is an expected state.
|
|
48
|
-
Adding a `test` instruction, will run the checks in the context of the atomic operation they are part of.
|
|
49
|
-
By default, atomic operations with failing tests are silently skipped.
|
|
50
|
-
|
|
51
|
-
```ts
|
|
52
|
-
// If the test operation passes, continue to add the new value
|
|
53
|
-
// If the test operation fails, all instructions are disregarded
|
|
54
|
-
packageJson.patch(
|
|
55
|
-
JsonPatch.test('/author/name', 'A. Noyed'),
|
|
56
|
-
JsonPatch.replace('/author/name', 'A. Mused'),
|
|
57
|
-
JsonPatch.add('/author/email', 'amused@example.com'),
|
|
58
|
-
);
|
|
59
|
-
|
|
60
|
-
// This will run regardless of the outcome previous statement
|
|
61
|
-
packageJson.patch(JsonPatch.add('/keywords/-', 'productivity'));
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
In certain situations you might want to fail the whole synthesis:
|
|
65
|
-
|
|
66
|
-
```ts
|
|
67
|
-
// Fails synthesis completely
|
|
68
|
-
packageJson.patch(
|
|
69
|
-
JsonPatch.test('/author/name', 'A. Noyed', TestFailureBehavior.FAIL_SYNTHESIS),
|
|
70
|
-
);
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
## Overrides
|
|
74
|
-
|
|
75
|
-
An alternative is to override properties through the `addOverride`, `addDeletionOverride`,
|
|
76
|
-
`addToArray` and `patch` methods accessible on the file component:
|
|
77
|
-
|
|
78
|
-
```ts
|
|
79
|
-
// Get the ObjectFile
|
|
80
|
-
const packageJson = project.tryFindObjectFile('package.json');
|
|
81
|
-
|
|
82
|
-
// Use dot notation to address inside the object
|
|
83
|
-
packageJson.addOverride('description', 'the next generation of logging!');
|
|
84
|
-
packageJson.addOverride('keywords', ['experimental', 'web', 'productivity', 'exciting']);
|
|
85
|
-
|
|
86
|
-
// Use one-based array indices to override specific array elements
|
|
87
|
-
packageJson.addOverride('funding.2.type', 'individual');
|
|
88
|
-
|
|
89
|
-
// New elements can be added to the end of an array
|
|
90
|
-
packageJson.addToArray('keywords', 'logging', 'next-gen');
|
|
91
|
-
|
|
92
|
-
// Values can be deleted
|
|
93
|
-
packageJson.addDeletionOverride('author.organization');
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
## Removing files
|
|
97
|
-
|
|
98
|
-
You can remove a file from the project through `tryRemoveFile` method on the
|
|
99
|
-
`Project` class.
|
|
100
|
-
|
|
101
|
-
```ts
|
|
102
|
-
new TextFile(project, "hello.txt", { lines: "original" });
|
|
103
|
-
|
|
104
|
-
project.tryRemoveFile("hello.txt");
|
|
105
|
-
|
|
106
|
-
new TextFile(project, "hello.txt", { lines: "better" });
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
> Note: It's recommended that this used carefully since removing files may be
|
|
110
|
-
unexpected for users depending on where it's used. For example, if you created a
|
|
111
|
-
component named `MyFancyGitIgnore` and had it remove any existing `.gitignore`
|
|
112
|
-
files in the project, then users may be surprised when customizations for their
|
|
113
|
-
existing `.gitignore` file are nullified.
|
package/docs/github.md
DELETED
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
# GitHub
|
|
2
|
-
|
|
3
|
-
By default, many projects are initialized with `GitHub` component to enabled GitHub as the default provider for CI/CD workflows. See <https://docs.github.com/en/actions> for more information.
|
|
4
|
-
|
|
5
|
-
The use of GitHub (and generating corresponding files in `.github`) can be disabled by specifying `github: false` in your project options.
|
|
6
|
-
|
|
7
|
-
## GitHub API access
|
|
8
|
-
|
|
9
|
-
Several workflows generated by projen use APIs that are not available through
|
|
10
|
-
the permissions of [GITHUB_TOKEN]. To use these workflows, you must provide
|
|
11
|
-
either a Personal Access Token (PAT) or a GitHub App to provide API access.
|
|
12
|
-
|
|
13
|
-
[GITHUB_TOKEN]: https://docs.github.com/en/actions/security-guides/automatic-token-authentication
|
|
14
|
-
|
|
15
|
-
### Personal Access Token (classic)
|
|
16
|
-
|
|
17
|
-
Follow the [GitHub docs
|
|
18
|
-
instructions](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token#creating-a-personal-access-token-classic)
|
|
19
|
-
for creating a personal access token (classic).
|
|
20
|
-
When creating the classic PAT, grant the token `repo`, `workflow` and `write:packages` permissions.
|
|
21
|
-
|
|
22
|
-
Add the token as a secret to your repo under the name `PROJEN_GITHUB_TOKEN`.
|
|
23
|
-
|
|
24
|
-
### Fine-grained Personal Access Token (beta)
|
|
25
|
-
|
|
26
|
-
Follow the [GitHub docs
|
|
27
|
-
instructions](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token#creating-a-fine-grained-personal-access-token)
|
|
28
|
-
for creating a fine-grained personal access token (beta).
|
|
29
|
-
|
|
30
|
-
Select the repositories you want to use this token for.
|
|
31
|
-
You can reuse the same token for multiple repositories if you select them here.
|
|
32
|
-
However you should choose the minimal repository access that meets your needs.
|
|
33
|
-
|
|
34
|
-
Under Permissions, select the following Repository Permissions:
|
|
35
|
-
|
|
36
|
-
- `Contents` - Read and write
|
|
37
|
-
- `Metadata` - Read-only (automatically added)
|
|
38
|
-
- `Pull requests` - Read and write
|
|
39
|
-
- `Workflows` - Read and write
|
|
40
|
-
|
|
41
|
-
Add the token as a secret to your repo under the name `PROJEN_GITHUB_TOKEN`.
|
|
42
|
-
|
|
43
|
-
### GitHub App
|
|
44
|
-
|
|
45
|
-
Follow the [GitHub docs instructions](https://docs.github.com/en/developers/apps/building-github-apps/creating-a-github-app) for creating a GitHub App. Enable read & write permission for "Contents" and "Pull Request" scopes.
|
|
46
|
-
|
|
47
|
-
Add the App ID as a secret to your repo under the name `PROJEN_APP_ID` and the private key you generate as a secret to your repo under the name `PROJEN_APP_PRIVATE_KEY`.
|
|
48
|
-
|
|
49
|
-
Then, configure your projenrc file to use the GitHub app for API access:
|
|
50
|
-
|
|
51
|
-
```ts
|
|
52
|
-
const { github, javascript } = require('projen');
|
|
53
|
-
|
|
54
|
-
const project = new javascript.NodeProject({
|
|
55
|
-
// ...other options
|
|
56
|
-
githubOptions: {
|
|
57
|
-
projenCredentials: github.GithubCredentials.fromApp({ ... }),
|
|
58
|
-
},
|
|
59
|
-
});
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
If the GitHub app you are using has additional permissions assigned, you can limit the permissions used on the token within the jobs in the workflow to only allow access to write repository contents and create the pull request:
|
|
63
|
-
|
|
64
|
-
```ts
|
|
65
|
-
const { github, javascript } = require('projen');
|
|
66
|
-
|
|
67
|
-
const project = new javascript.NodeProject({
|
|
68
|
-
// ...other options
|
|
69
|
-
githubOptions: {
|
|
70
|
-
projenCredentials: github.GithubCredentials.fromApp({
|
|
71
|
-
// ...other options
|
|
72
|
-
permissions: {
|
|
73
|
-
pullRequests: github.workflows.AppPermission.WRITE,
|
|
74
|
-
contents: github.workflows.AppPermission.WRITE,
|
|
75
|
-
}
|
|
76
|
-
}),
|
|
77
|
-
},
|
|
78
|
-
});
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
## Workflows
|
|
82
|
-
|
|
83
|
-
See the `GitHub`, `GithubWorkflow`, and `Job` types in the [API
|
|
84
|
-
reference](./api/API.md) for currently available APIs.
|
|
85
|
-
|
|
86
|
-
Example code of creating a GitHub workflow:
|
|
87
|
-
<https://github.com/projen/projen/blob/65b4194c163f47ba4842981b0c92dbe516be787b/src/github/auto-approve.ts#L67-L105>
|
|
88
|
-
|
|
89
|
-
### Actions versions
|
|
90
|
-
|
|
91
|
-
Most workflows included with projen are constraint to a major version, in order for updates to be available immediately.
|
|
92
|
-
However it is a good security practice to lock versions of GitHub Actions down to explicit commit hashes.
|
|
93
|
-
To achieve this, you can define explicit overrides for any action used in workflows.
|
|
94
|
-
|
|
95
|
-
The replace all occurrences of an action can be overridden, irregardless of the action version:
|
|
96
|
-
|
|
97
|
-
```ts
|
|
98
|
-
project.github.actions.set("actions/checkout", "actions/checkout@ac59398");
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
Any use of `actions/checkout` is now changed to this:
|
|
102
|
-
|
|
103
|
-
```yaml
|
|
104
|
-
steps:
|
|
105
|
-
- uses: actions/checkout@ac59398
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
Alternatively, any specific action version can be overridden.
|
|
109
|
-
This can be useful when a specific version of an action must be used due to incompatible changes.
|
|
110
|
-
Specific overrides take precedence over overrides without a version.
|
|
111
|
-
|
|
112
|
-
```ts
|
|
113
|
-
project.github.actions.set("actions/checkout@v3", "actions/checkout@ac59398");
|
|
114
|
-
project.github.actions.set("actions/checkout", "actions/checkout@main");
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
Different versions of `actions/checkout` are resolved to different overrides:
|
|
118
|
-
|
|
119
|
-
```yaml
|
|
120
|
-
steps:
|
|
121
|
-
# Was: actions/checkout@v3
|
|
122
|
-
- uses: actions/checkout@ac59398
|
|
123
|
-
|
|
124
|
-
# Was: actions/checkout@v2
|
|
125
|
-
- uses: actions/checkout@main
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
Workflow creators are encouraged to use commit hashes and keep them updated, or major versions.
|
|
129
|
-
Sensitive workflow actions should always use commit hashes.
|
|
130
|
-
|
|
131
|
-
### Stale workflow
|
|
132
|
-
|
|
133
|
-
A "stale" workflow can be added which will automatically close issues or pull
|
|
134
|
-
requests on your GitHub repository after time has passed without the issue
|
|
135
|
-
seeing any comments or updates. You can enable as shown below:
|
|
136
|
-
|
|
137
|
-
```ts
|
|
138
|
-
// or PythonProject, etc.
|
|
139
|
-
new typescript.TypeScriptProject({
|
|
140
|
-
stale: true,
|
|
141
|
-
staleOptions: {
|
|
142
|
-
issues: {
|
|
143
|
-
closeMessage: "closing pull request",
|
|
144
|
-
staleLabel: "I-AM-STALE",
|
|
145
|
-
daysBeforeStale: 180,
|
|
146
|
-
},
|
|
147
|
-
}
|
|
148
|
-
})
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
Check the API reference for a list of all available options.
|
|
152
|
-
|
|
153
|
-
When enabled, by default issues with no activity with will be marked as stale
|
|
154
|
-
after 60 days and closed within 7 days, and pull requests with no activity will
|
|
155
|
-
be marked as stale after 14 days and closed within 2 days.
|
package/docs/gitlab.md
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
# GitLab
|
|
2
|
-
|
|
3
|
-
[GitLab CI/CD](https://docs.gitlab.com/ee/ci/yaml/gitlab_ci_yaml.html) uses a `.gitlab-ci.yml` file located at the root of your repository to specify continuous integration and continuous deployment processes. GitLab CI configuration files can be split into multiple files using the [include](https://docs.gitlab.com/ee/ci/yaml/#include) fields in order to increase readability or reduce duplication of the same configuration in multiple places.
|
|
4
|
-
|
|
5
|
-
## Creating a configuration
|
|
6
|
-
|
|
7
|
-
We support the creation of GitLab CI/CD Configurations through a `CiConfiguration` class and a higher level `GitlabConfiguration` and `NestedConfiguration` classes. To create a GitLab configuration you must first create a [project](./project.md) to assign the configuration to.
|
|
8
|
-
|
|
9
|
-
When using GitLab for CI, the `.gitlab-ci.yml` is always located at the root of the project while other configuration files are located in the `.gitlab\ci-templates\` subdirectory.
|
|
10
|
-
|
|
11
|
-
```js
|
|
12
|
-
const { typescript, gitlab } = require('projen');
|
|
13
|
-
const project = new typescript.TypeScriptProject({
|
|
14
|
-
defaultReleaseBranch: 'main',
|
|
15
|
-
name: 'my-project',
|
|
16
|
-
});
|
|
17
|
-
const gitlabMain = new gitlab.GitlabConfiguration(project,
|
|
18
|
-
{
|
|
19
|
-
jobs: {
|
|
20
|
-
myJob: {
|
|
21
|
-
script: 'echo Hello',
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
});
|
|
25
|
-
gitlabMain.createNestedTemplates({
|
|
26
|
-
myNestedTemplate: {
|
|
27
|
-
jobs: {
|
|
28
|
-
myOtherJob: {
|
|
29
|
-
script: 'echo World!',
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
});
|
|
34
|
-
project.synth();
|
|
35
|
-
```
|
|
36
|
-
This creates the following directory structure.
|
|
37
|
-
|
|
38
|
-
```shell
|
|
39
|
-
├── .gitlab-ci.yml
|
|
40
|
-
└── .gitlab
|
|
41
|
-
└── ci-templates
|
|
42
|
-
└── mynestedtemplate.yml
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
## Updating Nested Configurations
|
|
46
|
-
|
|
47
|
-
You can modify a `NestedConfiguration` through the `nestedTemplates` property of a `GitlabConfiguration`.
|
|
48
|
-
```js
|
|
49
|
-
const { typescript, gitlab } = require('projen');
|
|
50
|
-
const project = new typescript.TypeScriptProject({
|
|
51
|
-
defaultReleaseBranch: 'main',
|
|
52
|
-
name: 'my-project',
|
|
53
|
-
});
|
|
54
|
-
const gitlabMain = new gitlab.GitlabConfiguration(project,
|
|
55
|
-
{
|
|
56
|
-
jobs: {
|
|
57
|
-
myJob: {
|
|
58
|
-
script: 'echo Hello',
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
});
|
|
62
|
-
gitlabMain.createNestedTemplates({
|
|
63
|
-
myNestedTemplate: {},
|
|
64
|
-
});
|
|
65
|
-
gitlabMain.nestedTemplates.myNestedTemplate.addStages('stage');
|
|
66
|
-
project.synth();
|
|
67
|
-
```
|