Skip to content

Commit

Permalink
chore: add verdaccio local release (#1308)
Browse files Browse the repository at this point in the history
* chore: add verdaccio local release

* chore: local publish with "ci" dist tag
  • Loading branch information
AllanZhengYP committed Jul 1, 2020
1 parent 8a6e304 commit 85866ff
Show file tree
Hide file tree
Showing 5 changed files with 1,004 additions and 79 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,6 @@ codegen/sdk-codegen/smithy-build.json
protocol_tests/*/coverage
protocol_tests/*/dist
protocol_tests/*/types

/verdaccio/*
!/verdaccio/config.yaml
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"test:functional": "jest --config tests/functional/jest.config.js --passWithNoTests",
"test:integration-legacy": "cucumber-js --fail-fast",
"test:integration": "jest --config jest.config.integ.js --passWithNoTests",
"test:protocols": "yarn build:protocols && lerna run test --scope '@aws-sdk/aws-*'"
"test:protocols": "yarn build:protocols && lerna run test --scope '@aws-sdk/aws-*'",
"local-publish": "node ./scripts/verdaccio-publish/index.js"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -70,6 +71,7 @@
"typescript": "~3.8.3",
"webpack": "^4.43.0",
"webpack-cli": "^3.3.12",
"verdaccio": "^4.7.2",
"yarn": "1.22.4"
},
"workspaces": {
Expand Down
50 changes: 50 additions & 0 deletions scripts/verdaccio-publish/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/env node
// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.

// Reference: https://github.com/aws/aws-encryption-sdk-javascript/pull/276

const { spawn, execSync } = require("child_process");
const pipeStdIo = { stdio: [process.stdin, process.stdout, process.stderr] };

execSync("rm -rf verdaccio/storage/@aws-sdk");

// Start verdaccio in the background
const verdaccio = spawn(
"npx",
["verdaccio", "-c", "verdaccio/config.yaml"],
pipeStdIo
).on("error", e => {
throw e;
});

// Publish all changed packages the local verdaccio server.
// Anything that has not been changed will match what is in npm
const args = [
"lerna",
"publish",
"prerelease",
"--preid",
"ci",
"--exact",
"--registry",
"http://localhost:4873/",
"--yes",
"--no-changelog",
"--no-git-tag-version",
"--no-push",
"--no-git-reset",
"--ignore-scripts",
"--no-verify-access",
"--dist-tag",
"ci"
];
spawn("npx", args, pipeStdIo).on("close", code => {
// Rollback the changes caused by the version bumping
execSync("git checkout -- clients/*/package.json");
execSync("git checkout -- packages/*/package.json");
execSync("git checkout -- protocol_tests/*/package.json");

// Kill the background verdaccio server
verdaccio.kill();
if (code !== 0) throw Error(`Exit code: ${code}`);
});
76 changes: 76 additions & 0 deletions verdaccio/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#
# This is the default config file. It allows all users to do anything,
# so don't use it on production systems.
#
# Look here for more config file examples:
# https://github.com/verdaccio/verdaccio/tree/master/conf
#

# path to a directory with all packages
storage: ./storage
# path to a directory with plugins to include
plugins: ./plugins

web:
title: Verdaccio
# comment out to disable gravatar support
# gravatar: false
# by default packages are ordercer ascendant (asc|desc)
# sort_packages: asc

auth:
htpasswd:
file: ./htpasswd
# Maximum amount of users allowed to register, defaults to "+inf".
# You can set this to -1 to disable registration.
# max_users: 1000

# a list of other known repositories we can talk to
uplinks:
npmjs:
url: https://registry.npmjs.org/

packages:
"@aws-sdk/*":
# scoped packages
access: $all
publish: $all
unpublish: $all
proxy: npmjs
"@*/*":
# scoped packages
access: $all
publish: $authenticated
unpublish: $authenticated
proxy: npmjs

"**":
# allow all users (including non-authenticated users) to read and
# publish all packages
#
# you can specify usernames/groupnames (depending on your auth plugin)
# and three keywords: "$all", "$anonymous", "$authenticated"
access: $all

# allow all known users to publish/publish packages
# (anyone can register by default, remember?)
publish: $authenticated
unpublish: $authenticated

# if package is not available locally, proxy requests to 'npmjs' registry
proxy: npmjs

# You can specify HTTP/1.1 server keep alive timeout in seconds for incomming connections.
# A value of 0 makes the http server behave similarly to Node.js versions prior to 8.0.0, which did not have a keep-alive timeout.
# WORKAROUND: Through given configuration you can workaround following issue https://github.com/verdaccio/verdaccio/issues/301. Set to 0 in case 60 is not enought.
server:
keepAliveTimeout: 60

middlewares:
audit:
enabled: true

# log settings
logs:
- { type: stdout, format: pretty, level: http }
#- {type: file, path: verdaccio.log, level: info}

0 comments on commit 85866ff

Please sign in to comment.