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.
Files changed (165) hide show
  1. package/.jsii +46 -46
  2. package/README.md +38 -33
  3. package/lib/awscdk/auto-discover.js +5 -5
  4. package/lib/awscdk/awscdk-app-java.js +1 -1
  5. package/lib/awscdk/awscdk-app-py.js +1 -1
  6. package/lib/awscdk/awscdk-app-ts.js +1 -1
  7. package/lib/awscdk/awscdk-construct.js +2 -2
  8. package/lib/awscdk/awscdk-deps-java.js +1 -1
  9. package/lib/awscdk/awscdk-deps-js.js +1 -1
  10. package/lib/awscdk/awscdk-deps-py.js +1 -1
  11. package/lib/awscdk/awscdk-deps.js +1 -1
  12. package/lib/awscdk/cdk-config.js +1 -1
  13. package/lib/awscdk/cdk-tasks.js +1 -1
  14. package/lib/awscdk/integration-test.js +1 -1
  15. package/lib/awscdk/lambda-extension.js +1 -1
  16. package/lib/awscdk/lambda-function.js +2 -2
  17. package/lib/build/build-workflow.js +1 -1
  18. package/lib/cdk/auto-discover-base.js +2 -2
  19. package/lib/cdk/construct-lib.js +1 -1
  20. package/lib/cdk/integration-test-base.js +1 -1
  21. package/lib/cdk/jsii-docgen.js +1 -1
  22. package/lib/cdk/jsii-project.js +1 -1
  23. package/lib/cdk8s/auto-discover.js +2 -2
  24. package/lib/cdk8s/cdk8s-app-py.js +1 -1
  25. package/lib/cdk8s/cdk8s-app-ts.js +1 -1
  26. package/lib/cdk8s/cdk8s-construct.js +1 -1
  27. package/lib/cdk8s/cdk8s-deps-py.js +1 -1
  28. package/lib/cdk8s/cdk8s-deps.js +1 -1
  29. package/lib/cdk8s/integration-test.js +1 -1
  30. package/lib/cdktf/cdktf-construct.js +1 -1
  31. package/lib/circleci/circleci.js +1 -1
  32. package/lib/component.js +1 -1
  33. package/lib/dependencies.js +1 -1
  34. package/lib/dev-env.js +1 -1
  35. package/lib/docker-compose/docker-compose-service.js +1 -1
  36. package/lib/docker-compose/docker-compose.js +1 -1
  37. package/lib/file.js +3 -3
  38. package/lib/gitattributes.js +1 -1
  39. package/lib/github/actions-provider.js +1 -1
  40. package/lib/github/auto-approve.js +1 -1
  41. package/lib/github/auto-merge.js +1 -1
  42. package/lib/github/dependabot.js +1 -1
  43. package/lib/github/github-credentials.js +1 -1
  44. package/lib/github/github-project.js +1 -1
  45. package/lib/github/github.js +1 -1
  46. package/lib/github/mergify.js +1 -1
  47. package/lib/github/pr-template.js +1 -1
  48. package/lib/github/pull-request-lint.js +1 -1
  49. package/lib/github/stale.js +1 -1
  50. package/lib/github/task-workflow.js +1 -1
  51. package/lib/github/workflow-actions.js +1 -1
  52. package/lib/github/workflow-jobs.js +1 -1
  53. package/lib/github/workflows.js +1 -1
  54. package/lib/gitlab/configuration.js +1 -1
  55. package/lib/gitlab/gitlab-configuration.js +1 -1
  56. package/lib/gitlab/nested-configuration.js +1 -1
  57. package/lib/gitpod.js +1 -1
  58. package/lib/ignore-file.js +1 -1
  59. package/lib/ini.js +1 -1
  60. package/lib/java/java-project.js +1 -1
  61. package/lib/java/junit.js +1 -1
  62. package/lib/java/maven-compile.js +1 -1
  63. package/lib/java/maven-packaging.js +1 -1
  64. package/lib/java/maven-sample.js +1 -1
  65. package/lib/java/pom.js +1 -1
  66. package/lib/java/projenrc.js +1 -1
  67. package/lib/javascript/bundler.js +1 -1
  68. package/lib/javascript/eslint.js +1 -1
  69. package/lib/javascript/jest.js +4 -4
  70. package/lib/javascript/node-package.js +1 -1
  71. package/lib/javascript/node-project.d.ts +2 -1
  72. package/lib/javascript/node-project.js +11 -6
  73. package/lib/javascript/npm-config.js +1 -1
  74. package/lib/javascript/prettier.js +1 -1
  75. package/lib/javascript/projenrc.js +1 -1
  76. package/lib/javascript/typescript-config.js +2 -2
  77. package/lib/javascript/upgrade-dependencies.d.ts +1 -1
  78. package/lib/javascript/upgrade-dependencies.js +3 -3
  79. package/lib/json-patch.js +1 -1
  80. package/lib/json.js +1 -1
  81. package/lib/license.js +1 -1
  82. package/lib/logger.js +1 -1
  83. package/lib/makefile.js +1 -1
  84. package/lib/object-file.js +1 -1
  85. package/lib/project-build.js +1 -1
  86. package/lib/project.d.ts +4 -4
  87. package/lib/project.js +6 -6
  88. package/lib/projects.js +1 -1
  89. package/lib/projenrc-json.js +2 -2
  90. package/lib/projenrc.js +1 -1
  91. package/lib/python/pip.js +1 -1
  92. package/lib/python/poetry.js +2 -2
  93. package/lib/python/projenrc.js +1 -1
  94. package/lib/python/pytest-sample.js +1 -1
  95. package/lib/python/pytest.js +1 -1
  96. package/lib/python/python-project.js +1 -1
  97. package/lib/python/python-sample.js +1 -1
  98. package/lib/python/requirements-file.js +1 -1
  99. package/lib/python/setuppy.js +1 -1
  100. package/lib/python/setuptools.js +1 -1
  101. package/lib/python/venv.js +1 -1
  102. package/lib/readme.js +1 -1
  103. package/lib/release/publisher.js +1 -1
  104. package/lib/release/release-trigger.js +1 -1
  105. package/lib/release/release.js +1 -1
  106. package/lib/renovatebot.js +1 -1
  107. package/lib/sample-file.js +2 -2
  108. package/lib/semver.js +1 -1
  109. package/lib/source-code.js +1 -1
  110. package/lib/task-runtime.js +1 -1
  111. package/lib/task.js +1 -1
  112. package/lib/tasks.js +1 -1
  113. package/lib/testing.js +1 -1
  114. package/lib/textfile.js +1 -1
  115. package/lib/toml.js +1 -1
  116. package/lib/typescript/projenrc-ts.js +1 -1
  117. package/lib/typescript/projenrc.js +1 -1
  118. package/lib/typescript/typescript-typedoc.js +1 -1
  119. package/lib/typescript/typescript.js +3 -3
  120. package/lib/util.d.ts +1 -0
  121. package/lib/util.js +2 -1
  122. package/lib/version.js +2 -2
  123. package/lib/vscode/devcontainer.js +1 -1
  124. package/lib/vscode/extensions.js +1 -1
  125. package/lib/vscode/launch-config.js +1 -1
  126. package/lib/vscode/settings.js +1 -1
  127. package/lib/vscode/vscode.js +1 -1
  128. package/lib/web/next.js +3 -3
  129. package/lib/web/postcss.js +1 -1
  130. package/lib/web/react.js +4 -4
  131. package/lib/web/tailwind.js +1 -1
  132. package/lib/xmlfile.js +1 -1
  133. package/lib/yaml.js +1 -1
  134. package/package.json +1 -1
  135. package/.prettierignore +0 -1
  136. package/.prettierrc.json +0 -3
  137. package/docs/CNAME +0 -1
  138. package/docs/README.md +0 -28
  139. package/docs/api/API.md +0 -21296
  140. package/docs/awscdk-apps.md +0 -18
  141. package/docs/awscdk-construct.md +0 -195
  142. package/docs/awscdk.md +0 -377
  143. package/docs/build.md +0 -55
  144. package/docs/bundling.md +0 -30
  145. package/docs/cdk8s.md +0 -39
  146. package/docs/circleci.md +0 -87
  147. package/docs/components.md +0 -21
  148. package/docs/deps.md +0 -62
  149. package/docs/eject.md +0 -30
  150. package/docs/escape-hatches.md +0 -113
  151. package/docs/github.md +0 -155
  152. package/docs/gitlab.md +0 -67
  153. package/docs/java.md +0 -213
  154. package/docs/node.md +0 -150
  155. package/docs/programmatic-api.md +0 -56
  156. package/docs/publisher.md +0 -148
  157. package/docs/python.md +0 -169
  158. package/docs/releases.md +0 -191
  159. package/docs/subproject.md +0 -37
  160. package/docs/tasks.md +0 -211
  161. package/docs/typescript.md +0 -119
  162. package/logo/projen.svg +0 -211
  163. package/rfcs/github-project-settings.md +0 -95
  164. package/rfcs/project-creation-prompt.md +0 -95
  165. package/version.json +0 -3
package/docs/python.md DELETED
@@ -1,169 +0,0 @@
1
- # Python Projects
2
-
3
- Before creating a new project, make sure you have the version of Python you want
4
- to use set up in your terminal. Running `which python` on UNIX/macOS or
5
- `Get-Command python` on Windows should print the path to the python version you
6
- want to use.
7
-
8
- To create a new Python project, use `projen new python`:
9
-
10
- ```shell
11
- $ projen new python --name=my-project
12
- ```
13
-
14
- This will synthesize a standard project directory structure with some sample
15
- code.
16
-
17
- ```shell
18
- โ”œโ”€โ”€ my_project
19
- โ”‚ย ย  โ”œโ”€โ”€ __init__.py
20
- โ”‚ย ย  โ”œโ”€โ”€ __main__.py
21
- โ”‚ย ย  โ””โ”€โ”€ example.py
22
- โ””โ”€โ”€ tests
23
- โ”œโ”€โ”€ __init__.py
24
- โ””โ”€โ”€ test_example.py
25
- ```
26
-
27
- The default options will setup a Python environment using `venv`, and will
28
- create a `requirements.txt` file for installing dependencies via `pip`.
29
-
30
- The `projen new` command will also generate a `.projenrc.py` file which includes
31
- the definition of your project with any options you specified in the command
32
- line:
33
-
34
- ```python
35
- from projen.python import PythonProject
36
-
37
- project = PythonProject(
38
- author_email="Author email",
39
- author_name="Author name",
40
- module_name="your_python_project",
41
- name="project_name",
42
- version="0.1.0",
43
- )
44
-
45
- project.synth()
46
- ```
47
-
48
- To modify your project definitions, edit `.projenrc.py` and run `projen` again
49
- to re-synthesize your project. The following sections describe the various features of Python projects.
50
-
51
- ## Managing environments, dependencies, and packaging
52
-
53
- Every Python project must have a component for managing/installing dependencies,
54
- a component for managing the Python virtual environment, and if it is a library,
55
- a component for packaging the library. Some components satisfy multiple
56
- requirements. See the list below:
57
-
58
- - pip: dependency manager
59
- - venv: environment manager
60
- - setuptools: packaging manager
61
- - poetry: dependency, environment, and packaging manager
62
- - pipenv (TBD): dependency and environment manager
63
- - conda (TBD): dependency and environment manager
64
-
65
- By default, pip, and venv will be used, along with setuptools if the project is a library:
66
-
67
- ```python
68
- from projen import ProjectType
69
- from projen.python import PythonProject
70
-
71
- project = PythonProject(
72
- ...
73
- project_type=ProjectType.LIB
74
- )
75
- ```
76
-
77
- But these can be swapped out as needed by using the provided flags, for example:
78
-
79
- ```python
80
- from projen.python import PythonProject
81
-
82
- project = PythonProject(
83
- ...
84
- pip=False,
85
- venv=False,
86
- setuptools=False,
87
- poetry=True
88
- )
89
- ```
90
-
91
- ## Dependencies
92
-
93
- Python projects have two types of supported dependencies:
94
-
95
- 1. Runtime dependencies (or just "dependencies").
96
- 2. Development dependencies
97
-
98
- You can define dependencies when defining the project itself:
99
-
100
- ```python
101
- from projen.python import PythonProject
102
-
103
- project = PythonProject(
104
- ...
105
- deps=[
106
- 'Django@3.1.5',
107
- 'aws-cdk.core', # implies"@*"
108
- ],
109
- dev_deps=[
110
- 'hypothesis@^6.0.3',
111
- ]
112
- )
113
- ```
114
-
115
- Or using the APIs:
116
-
117
- ```python
118
- project.add_dev_dependency('hypothesis@^6.0.3');
119
- ```
120
-
121
- Notice the syntax for dependencies:
122
-
123
- ```text
124
- <module>[@version]
125
- ```
126
-
127
- Where `module` is the module name and `version` is the [semantic version
128
- requirement](https://semver.org) for the dependency. The semver syntax will be
129
- converted to the appropriate dependency manager syntax in synthesized files. For
130
- example, `lib^3.1.0` will be converted to `lib>=3.1.0, <4.0.0` in
131
- `requirements.txt`.
132
-
133
- ### Poetry Dependencies
134
-
135
- When using the `poetry` project type, note the following:
136
-
137
- * The `[@version]` part of the dependency declaration must be present for all dependencies
138
- * Dependencies that require additional metadata regarding extras etc. may be declared as
139
- follows:
140
-
141
- ```text
142
- deps: [
143
- ...
144
- "mypackage@{version = '^3.3.3', extras = ['mypackage-extra']}",
145
- ],
146
- ```
147
-
148
- ## Unit Testing with Pytest
149
-
150
- The `Pytest` component adds support for writing Python tests with
151
- [pytest](https://pytest.org/). The component will add the required test
152
- dependencies to your project.
153
-
154
- Test sources are placed under `tests` and can be executed via `projen test`.
155
-
156
- To disable pytest tests, set `pytest: false` when you define the
157
- `PythonProject`.
158
-
159
- ## `projenrc.py`
160
-
161
- ## Packaging and Publishing
162
-
163
- Python projects can be packaged by using either the `Setuptools` or `Poetry`
164
- component. `Setuptools` records package metadata within a traditional `setup.py`
165
- script, while `Poetry` stores metadata in the more-recent `pyproject.toml` file
166
- format as introduced in PEP 518.
167
-
168
- Run `projen package` to generate a source distribution and wheel, and run
169
- `projen upload` to upload the package to PyPI.
package/docs/releases.md DELETED
@@ -1,191 +0,0 @@
1
- # Releases and Versioning
2
-
3
- Projen takes care of managing versioning and releases of your project.
4
-
5
- The release model is based on (scaled) [trunk-based development](https://trunkbaseddevelopment.com/) and relies on [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) and [Semantic Versioning](https://semver.org/)
6
- to automatically determine the next version for every release.
7
-
8
- This means that commits to the default branch (`main`) are considered ready for production and by default every commit will be released and published to package managers.
9
-
10
- ## Initial development phase
11
-
12
- New projects start with version `0.0.0`.
13
- Anything may change at any time and public APIs should not be considered stable.
14
- Commits marked as a breaking change will increase the *minor* version. All other commits will increase the *patch* version.
15
-
16
- Projen will **never** release `v1.0.0` without your intervention. Once the project is ready, you have to make a one-time change to bump the major version.
17
-
18
- ## Major Versions
19
-
20
- To bump the major version for the default branch, set the `majorVersion` option to the desired version and push the change.
21
- For example:
22
-
23
- ```js
24
- majorVersion: 1
25
- ```
26
-
27
- For major versions 1 and above, if a release includes `fix` commits *only*, it will increase the *patch* version.
28
- If a release includes any `feat` commits, then the new version will be a *minor* version.
29
-
30
- ## Prerelease Versions
31
-
32
- To release prerelease versions from the main branch, set the `prerelease` option to the desired prerelease prefix.
33
- For example:
34
-
35
- ```js
36
- prerelease: 'beta'
37
- ```
38
-
39
- You can also use this with release branches or manual releases (see example below).
40
-
41
- ## Breaking Changes
42
-
43
- Conventional Commits allows changes to be marked as breaking by appending a `!` after the type/scope in the commit message or adding a `BREAKING CHANGE:` footer ([see examples](https://www.conventionalcommits.org/en/v1.0.0/#examples)).
44
-
45
- If a release includes breaking changes and the major version was not explicitly updated at the same time, **the release will fail**.
46
-
47
- If you rather want to automatically release major versions,
48
- use `minMajorVersion` instead of `majorVersion` and breaking changes will now increase the major version:
49
-
50
- ```js
51
- minMajorVersion: 1
52
- ```
53
-
54
- In the initial development phase of major version zero, breaking changes will never fail the release and instead increase the *minor* version (see above).
55
-
56
- ## Release Branches
57
-
58
- You can release multiple major versions from different branches at the same time through the `releaseBranches` option.
59
- A separate workflow will be created for each release branch to publish the commits to this branch.
60
-
61
- Each release branch must be associated with a different version.
62
-
63
- Normally it is sufficient to specify only `majorVersion`. If fixes to an earlier minor version should be released, `minorVersion` can also be specified.
64
-
65
- ```js
66
- releaseBranches: {
67
- '2.0': {
68
- majorVersion: 2,
69
- minorVersion: 0,
70
- },
71
- '2.x': {
72
- majorVersion: 2,
73
- },
74
- '3.x': {
75
- majorVersion: 3,
76
- prerelease: 'beta',
77
- },
78
- }
79
- ```
80
-
81
- ## Release Triggers
82
-
83
- If the project type supports it, then you can specify a `releaseTrigger`. You can use this to control whether
84
- or not your releases are automated as well as any unique artifacts associated with releases such as project-level
85
- changelogs.
86
-
87
- ```js
88
- releaseTrigger: ReleaseTrigger.scheduled({ schedule: '0 17 * * *' }),
89
- ```
90
-
91
- ## Selective Releases
92
-
93
- It is possible to only bump the version on a subset of commits.
94
- For example you could only release a new version for every feature and fix that was added to the repo.
95
-
96
- ```js
97
- releasableCommits: ReleasableCommits.featuresAndFixes(),
98
- ```
99
-
100
- This check only runs according to the release trigger, but serves as an additional check to not create unnecessary releases.
101
-
102
- A custom check can be implemented `ReleasableCommits.exec()`.
103
- This command should return a list of commit hashes that are considered releasable.
104
- I.e. to not not bump the version, the command must print nothing and exit successfully.
105
-
106
- ```js
107
- releasableCommits: ReleasableCommits.exec("./custom-script.sh"),
108
- ```
109
-
110
- ## Manual Releases
111
-
112
- If you don't want projen to automatically release your project, you can configure a manual release trigger:
113
-
114
- ```js
115
- releaseTrigger: ReleaseTrigger.manual(),
116
- ```
117
-
118
- This will create a `release` task. Run it locally (`projen release`) to cut a release. It will build the project and create releasable artifacts inside the `dist` directory.
119
-
120
- It will also trigger a `publish:git` task. This task does
121
- manage a project-level changelog, commit any changes, tag the release, and push any commits and tags to the remote repository.
122
-
123
- The command used for pushing can be customized by specifying
124
- `gitPushCommand`. Set to an empty string to disable pushing entirely.
125
-
126
- ### Publishing modules for manual releases
127
-
128
- With manual releases, projen will *not* automatically publish packages to their respective package repositories.
129
- You are expected to publish release artifacts from the `dist` directory manually.
130
-
131
- Please note that the repository itself will **not** be a releasable state. Publishing anything else but the release artifacts from `dist`, will fail.
132
-
133
- For example in a Node.js project, you might run:
134
-
135
- - `projen release` *(runs tests & builds a releasable artifact)*
136
- - `npm publish dist/js/my-package-1.2.3.tgz`
137
-
138
- Or for a multi language jsii project, the necessary steps could look something like:
139
-
140
- - `projen release`
141
- - `npx -p publib@latest publib-npm`
142
- - `npx -p publib@latest publib-pypi`
143
- - `npx -p publib@latest publib-nuget`
144
-
145
- It is also your responsibility to ensure credentials are setup and available for each package repository published to.
146
-
147
- ## FAQ
148
-
149
- ### How can I force a different version?
150
-
151
- You may be adopting projen in a project that has already been published to previous versions.
152
- Projen uses tags to determine the version to start with before bumping according to the rules previously mentioned.
153
-
154
- You can force the base version number by adding a tag to your repo. For example, if the latest version of your project is 1.2.3, then add a tag to your main branch of `v1.2.3`.
155
- The next time the release workflow runs, it will bump from version 1.2.3.
156
- As explained above, this is based on the conventional commits so the next release will either be 1.2.4, 1.3.0, or 2.0.0 on a breaking change.
157
-
158
- ### Can I change the format of the release tag?
159
-
160
- Yes, it is possible to change the tag prefix:
161
-
162
- ```js
163
- releaseTagPrefix: 'stable/'
164
- ```
165
-
166
- Please note that this also changes the behavior of finding existing tags and projen will now be looking for tags like `stable/1.2.3` to determine the current version.
167
- If you are migrating to a new tag format, make sure to re-tag at least the current version with the new format.
168
-
169
- The default prefix for release tags is `v*`. So if `releaseTagPrefix` is not defined in your `.projenrc.js` configuration you must define your tags as `v1.0.0`, `v2.0.0.0` and so on.
170
-
171
- ### Why is the version in `package.json` set to `0.0.0`?
172
-
173
- Projen uses tags to keep track of the current version of the project.
174
- While Node.js packages natively track theirs versions in `package.json`, not all languages supported by projen provide a mechanism like this.
175
- Consequently projen uses git tags as a mechanism that is independent of any target language.
176
- To convey this message, the version in `package.json` is kept at `0.0.0`.
177
-
178
- Additionally, Node.js packages are often published directly by running `npm publish` in the root of the repository.
179
- This does not work in projen.
180
- Instead, projen requires you to run `projen release` to create releasable artifacts and manually publish these artifacts.
181
-
182
- ### Can I do a manual one-off prerelease?
183
-
184
- If you wanted to generate a manual prerelease you can set the `PRERELEASE` environment variable.
185
-
186
- For example in a Node.js project, you might run:
187
-
188
- - `PRERELEASE=beta projen release` *(runs tests & builds a releasable artifact)*
189
- - `npm publish dist/js/my-package-1.2.3-beta.0.tgz`
190
-
191
- Make sure to also read the [Manual Releases](#manual-releases) section above.
@@ -1,37 +0,0 @@
1
- # Subprojects
2
-
3
- * Pass a project to the `parent` prop
4
- * `outdir` must be specified in project props for a subproject
5
-
6
- ## Example Subproject
7
-
8
- ```js
9
- // .projenrc.js
10
-
11
- const { AwsCdkTypeScriptApp, web } = require('projen');
12
-
13
- const nextProject = new web.NextJsProject({
14
- name: 'my-frontend'
15
- });
16
-
17
- nextProject.synth();
18
-
19
- const pipelineProject = new AwsCdkTypeScriptApp({
20
- name: 'my-frontend-pipeline',
21
- parent: nextProject,
22
- outdir: 'pipeline',
23
-
24
- cdkVersion: '1.78.0',
25
- cdkDependencies: [
26
- '@aws-cdk/aws-cloudfront',
27
- '@aws-cdk/aws-s3',
28
- '@aws-cdk/aws-s3-deployment',
29
- '@aws-cdk/core'
30
- ]
31
- });
32
-
33
- pipelineProject.synth();
34
- ```
35
-
36
- By default, GitHub workflows will not be created for subprojects since config
37
- files in `.github/` only work if they are in the root directory.
package/docs/tasks.md DELETED
@@ -1,211 +0,0 @@
1
- # Tasks
2
-
3
- Tasks are a project-level feature to define a project command system backed by
4
- shell scripts. Tasks are used to implement development workflows and are
5
- accessible through the projen CLI as subcommands.
6
-
7
- The following example defines a task named "hello" which executes the shell
8
- command `echo hello, world!`:
9
-
10
- ```js
11
- const hello = project.addTask('hello');
12
- hello.exec('echo hello, world!');
13
- ```
14
-
15
- Run `pj` and the task will be available in the CLI:
16
-
17
- ```shell
18
- $ projen hello
19
- ๐Ÿค– hello | echo hello, world!
20
- hello, world!
21
- ```
22
-
23
- You can also define some metadata and the first exec step declaratively:
24
-
25
- ```js
26
- const projen = require('projen');
27
-
28
- const hello = project.addTask('hello', {
29
- description: 'say hello',
30
- category: projen.tasks.TaskCategory.TEST,
31
- exec: 'echo hello, world!'
32
- });
33
- ```
34
-
35
- ## Steps
36
-
37
- Tasks can include any number of _steps_:
38
-
39
- ```ts
40
- hello.exec('echo step number 2');
41
-
42
- // a name can be added to a step if desired
43
- hello.exec('echo foo bar', { name: 'print the text "foo bar"' });
44
- ```
45
-
46
- The `--inspect` option can be used to display the contents of a task:
47
-
48
- ```shell
49
- $ projen hello --inspect
50
- echo hello, world!
51
- echo step number 2
52
- echo foo bar
53
- ```
54
-
55
- If a step fails, the task will fail and all subsequent steps will not be
56
- executed.
57
-
58
- You can also add steps to the beginning of a task:
59
-
60
- ```ts
61
- const hello = project.addTask('hello');
62
- hello.exec('echo hello');
63
- hello.prepend('echo world');
64
- ```
65
-
66
- Then:
67
-
68
- ```shell
69
- $ projen hello 2> /dev/null
70
- world
71
- hello
72
- ```
73
-
74
- ## Subtasks
75
-
76
- Tasks can also spawn sub-tasks as a step:
77
-
78
- ```ts
79
- const world = project.addTask('world');
80
- world.exec('echo world!');
81
-
82
- const hello = project.addTask('hello');
83
- hello.exec('echo hello');
84
- hello.spawn(world);
85
- ```
86
-
87
- The output will be:
88
-
89
- ```shell
90
- $ projen hello
91
- ๐Ÿค– hello | echo hello
92
- hello
93
- ๐Ÿค– hello ยป world | echo world!
94
- world!
95
-
96
- $ projen hello --inspect
97
- echo hello
98
- world:
99
- echo world!
100
- ```
101
-
102
- ## Environment
103
-
104
- Environment variables can be defined at the project level (for all tasks), the task level, or the task step level:
105
-
106
- ```ts
107
- project.tasks.addEnvironment('FOO', 'hello');
108
-
109
- const hello = project.addTask('hello');
110
- hello.env('BAR', 'beautiful');
111
- hello.exec('echo $FOO, $BAR $BAZ!', { env: { BAZ: 'world' } });
112
- ```
113
-
114
- Then:
115
-
116
- ```shell
117
- $ projen hello
118
- ๐Ÿค– hello | echo $FOO, $BAR $BAZ!
119
- hello, beautiful world!
120
- ```
121
-
122
- You can also evaluate environment variable values from a shell command:
123
-
124
- ```ts
125
- const hello = project.addTask('hello');
126
- hello.env('TIME', '$(date)');
127
- hello.exec('echo current time is $TIME');
128
- ```
129
-
130
- Then:
131
-
132
- ```shell
133
- $ projen hello
134
- ๐Ÿค– hello | echo current time is $TIME
135
- current time is Tue Dec 1 09:32:33 IST 2020
136
- ```
137
-
138
- ## Conditions
139
-
140
- The `condition` option includes a command that determines if the task is
141
- executed. If the command exits successfully (with a zero exit code), steps will
142
- be executed. Otherwise, the task will be skipped (successfully).
143
-
144
- ```ts
145
- const hello = project.addTask('hello', {
146
- condition: '[ -n "$CI" ]', // only execute if the CI environment variable is defined
147
- exec: 'echo running in a CI environment'
148
- });
149
- ```
150
-
151
- Then:
152
-
153
- ```shell
154
- $ projen hello
155
- ๐Ÿค– hello | condition: [ -n "$CI" ]
156
- ๐Ÿค– hello | condition exited with non-zero - skipping
157
-
158
- $ CI=1 projen hello
159
- ๐Ÿค– hello | condition: [ -n "$CI" ]
160
- ๐Ÿค– hello | echo running in a CI environment
161
- running in a CI environment
162
- ```
163
-
164
- The `condition` option can also be specified on individual task steps, for more
165
- granular control over task execution behavior:
166
-
167
- ```ts
168
- const hello = project.addTask('hello', {
169
- steps: [
170
- { exec: 'running in a CI environment', condition: '[ -n "$CI" ]' },
171
- { exec: 'not running in a CI environment', condition: '[ ! -n "$CI" ]' }
172
- ]
173
- });
174
- ```
175
-
176
- Then:
177
-
178
- ```shell
179
- $ projen hello
180
- ๐Ÿค– hello | condition: [ -n "$CI" ]
181
- ๐Ÿค– hello | condition exited with non-zero - skipping
182
- ๐Ÿค– hello | condition: [ ! -n "$CI" ]
183
- ๐Ÿค– hello | echo not running in a CI environment
184
- not running in a CI environment
185
-
186
- $ CI=1 projen hello
187
- ๐Ÿค– hello | condition: [ -n "$CI" ]
188
- ๐Ÿค– hello | echo running in a CI environment
189
- running in a CI environment
190
- ๐Ÿค– hello | condition: [ ! -n "$CI" ]
191
- ๐Ÿค– hello | condition exited with non-zero - skipping
192
- ```
193
-
194
- ## Tasks as npm scripts
195
-
196
- By default, npm scripts in `NodeProject`s (or derivatives) are implemented by delegating the
197
- command to the projen CLI:
198
-
199
- ```json
200
- {
201
- "scripts": {
202
- "compile": "npx projen compile"
203
- }
204
- }
205
- ```
206
-
207
- This means that when `yarn compile` or `npm run compile` are executed, the
208
- projen CLI will be invoked and the task will be executed.
209
-
210
- You can see a list of all steps in a task from the command line by passing
211
- the `--inspect` flag, e.g. `yarn compile --inspect`.