This repository has been archived by the owner on Nov 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a publish flow with "without-cli" version
- Loading branch information
1 parent
3cc18eb
commit b930d47
Showing
4 changed files
with
103 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: Npm publish | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
paths: | ||
- package.json | ||
|
||
jobs: | ||
npm-publish: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: 12 | ||
registry-url: https://registry.npmjs.org/ | ||
- run: yarn | ||
- run: yarn build | ||
- run: npm publish | ||
env: | ||
NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}} | ||
npm-publish-without-cli: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: 12 | ||
registry-url: https://registry.npmjs.org/ | ||
- run: yarn | ||
- run: yarn build | ||
- run: node publish-without-cli.js | ||
- run: npm publish --tag without-cli | ||
env: | ||
NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* Script to produce a `-without-cli` restful-react version. | ||
* | ||
* This produce a very lightweight build, without the cli script, | ||
* this is for easier security auditing and projects that don't use | ||
* our amazing open-api generator. | ||
* | ||
* This is executed just after `yarn build`, so the `/dist` is present. | ||
*/ | ||
const { readFileSync, writeFileSync } = require("fs"); | ||
const util = require("util"); | ||
const pick = require("lodash/pick"); | ||
const omit = require("lodash/omit"); | ||
const rimraf = util.promisify(require("rimraf")); | ||
|
||
const restfulReactDeps = ["lodash", "lodash-es", "qs", "react-fast-compare", "url"]; | ||
const packageJSON = JSON.parse(readFileSync("package.json", "utf-8")); | ||
|
||
// Dummy check to be sure we don't forgot a new package in the `-without-cli` version. | ||
if (Object.keys(packageJSON.dependencies).length !== 16) { | ||
throw new Error("The number of dependencies has changed! Please update `publish-without-cli`"); | ||
} | ||
|
||
// Create a package.json without the cli dependencies | ||
const lightPackageJSON = omit(packageJSON, "bin", "scripts", "husky", "devDependencies"); | ||
lightPackageJSON.dependencies = pick(packageJSON.dependencies, ...restfulReactDeps); | ||
lightPackageJSON.version = packageJSON.version + "-without-cli"; | ||
|
||
// Delete cli folders | ||
Promise.all([rimraf("dist/bin"), rimraf("dist/scripts")]).then(() => { | ||
// Replace the package.json | ||
writeFileSync("package.json", JSON.stringify(lightPackageJSON, null, 2)); | ||
|
||
// npm publish --tag without-cli | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters