Table of contents:
- π Quick Start (local development)
- π Continuous Delivery
- π¦ Options
- π Configuration File
- π§ Essential considerations
- π Next milestones
- π Do you Want to Contribute?
- License
- Recognitions
Note: all the examples are focused on Nx, if you don't see an explicit command for an Angular workspace just change
nx
forng
.Also, when you find references to
workspace.json
, you can find your file under the nameangular.json
.
-
Add
ngx-deploy-npm
to your project. It will configure all your publishable libraries present in the project:-
Nxπ¬
npm install --save-dev ngx-deploy-npm nx generate ngx-deploy-npm:install
-
Angular
π °οΈ ng add ngx-deploy-npm
-
-
Deploy your library to NPM with all default settings.
nx deploy your-library --dry-run
-
When you are happy with the result, remove the
--dry-run
option
Independently of the CI/CD that you are using you must create an NPM token. To do so, you have two methods
- Via NPM web page
- Using
npm token create
-
Set the env variable
- On your project setting ser the env variable. Let's call it
NPM_TOKEN
- On your project setting ser the env variable. Let's call it
-
Indicate how to find the token
- Before publishing, we must indicate to npm how to find that token,
do it by creating a step with
run: echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' > YOUR_REPO_DIRECTORY/.npmrc
- Replace
YOUR_REPO_DIRECTORY
for the path of your project, commonly is/home/circleci/repo
- Before publishing, we must indicate to npm how to find that token,
do it by creating a step with
-
(Optional) check that you are logged
- Creating a step with
run: npm whoami
- The output should be the username of your npm account
- Creating a step with
-
Deploy your package
- Create a step with:
Nxπ¬ Angular π °οΈ nx deploy your-library
ng deploy your-library
-
Enjoy your just released package ππ¦
The job full example is for an Angular project is
# .circleci/config.yml
jobs:
init-deploy:
executor: my-executor
steps:
- attach_workspace:
at: /home/circleci/repo/
# Set NPM token to be able to publish
- run: echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' > /home/circleci/repo/.npmrc
- run: npm whoami
- run: npx nx deploy YOUR_PACKAGE
You can check the steps suggested in the CircleCI's guide
- optional
- Default: Doesn't have any default value (string)
- Example:
nx deploy --build-target=production
β The configurationproduction
is being used to build your package
The buildTarget
simply points to an existing target configuration on your project,
as specified in the configurations
section of workspace.json
.
This is equivalent to calling the command nx build --configuration=XXX
.
This command has no effect if the option --no-build
option is active.
- optional
- Default:
false
(string) - Example:
nx deploy
β Angular project is build in production mode before the deploymentnx deploy --no-build
β Angular project is NOT build
Skip build process during deployment.
This can be used when you are sure that you haven't changed anything and want to deploy with the latest artifact.
This command causes the --build-target
setting to have no effect.
- optional
- Default: Doesn't have any default value (string)
- Example:
nx deploy --package-version 2.3.4
It's going to put that version on your package.json
and publish the library with that version on NPM.
- optional
- Default:
latest
(string) - Example:
nx deploy --tag alpha
β Your package will be available for download using that tag,npm install your-package@alpha
useful for RC versions, alpha, betas.
Registers the published package with the given tag, such that npm install @
will install this version. By default, npm publish
updates and npm install
installs the latest
tag. See npm-dist-tag
for details about tags.
- Default:
public
(string) - Example:
nx deploy --access public
Tells the registry whether this package should be published as public or restricted. It only applies to scoped packages, which default to restricted. If you donβt have a paid account, you must publish with --access public to publish scoped packages.
- optional
- Default: Doesn't have any default value (string)
- Example:
nx deploy --otp TOKEN
If you have two-factor authentication enabled in auth-and-writes mode then you can provide a code from your authenticator with this.
- optional
- Default:
false
(boolean) - Example:
nx deploy --dry-run
For testing: Run through without making any changes. Execute with --dry-run
, and nothing will happen. It will show a list of the options used on the console.
To avoid all these command-line cmd options, you can write down your
configuration in the workspace.json
file in the options
attribute
of your deploy project's executor.
Just change the option to lower camel case.
A list of all available options is also available here.
Example:
nx deploy your-library --tag alpha --access public --dry-run
becomes
"deploy": {
"executor": "ngx-deploy-npm:deploy",
"options": {
"tag": "alpha",
"access": "public",
"dryRun": "true"
}
}
Now you can just run nx deploy YOUR-LIBRARY
without all the options in the command line! π
βΉοΈ You can always use the --dry-run option to verify if your configuration is right.
Those files must be at the root of the library. The executor is copying them at the moment of building.
If you have those files outside the project's root, use the option assets
on the executor that compiles your application.
This deployer doesn't bump or generates a new version of the package, it just builds the package/library, take the package.json as it and publish it. You can use --package-version
option to change it.
For Nx workspace, only publishable libraries are going to be configured
We are looking forward to the following features:
- Implement Continuous Everything with Github Actions
- Specify which library configure the builder on the installment (
init
)
Your feature that's not on the list yet?
We look forward to any help. PRs are welcome! π
We create a special document for you to give you through this path
Code released under the MIT license.
- π Initially Powered By ngx-deploy-starter