Skip to content

Commit

Permalink
test: fix ci tests
Browse files Browse the repository at this point in the history
  • Loading branch information
antongolub committed Jun 17, 2022
1 parent e38ecd3 commit 77870b9
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ node_modules/
jspm_packages/

# npm creds
.npmrc
.yarnrc
.pnpmrc
**/.npmrc
**/.yarnrc
**/.pnpmrc

# TypeScript v1 declaration files
typings/
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"exports": "./src/main/js/index.js",
"type": "module",
"scripts": {
"test": "c8 uvu ./src/test -i fixtures -i utils && c8 report -r lcov",
"test": "NPM_REGISTRY='http://localhost:4873' NPM_TOKEN='mRv6eIuiaggXGb9ZDFCtBA==' c8 uvu ./src/test -i fixtures -i utils && c8 report -r lcov",
"docs": "mkdir -p docs && cp ./README.md ./docs/README.md"
},
"dependencies": {
Expand Down
10 changes: 7 additions & 3 deletions src/main/js/publish.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {formatTag, getLatestTag} from './tag.js'
import {tempy, ctx, fs, path} from 'zx-extra'
import {tempy, ctx, fs, path, $} from 'zx-extra'
import {copydir} from 'git-glob-cp'

const branches = {}
Expand Down Expand Up @@ -38,7 +38,7 @@ export const push = async ({cwd, from, to, branch, origin, msg, ignoreFiles}) =>
await $.raw`git push origin HEAD:refs/heads/${branch}`
})

export const publish = async (pkg, env, registry = 'http://localhost:4873/') => ctx(async ($) => {
export const publish = async (pkg, env) => ctx(async ($) => {
const {name, version, files} = pkg.manifest
const cwd = pkg.absPath
$.cwd = cwd
Expand All @@ -57,8 +57,12 @@ export const publish = async (pkg, env, registry = 'http://localhost:4873/') =>
console.log('push artifact to branch `meta`')
await push({cwd, from, to, branch: 'meta', msg: `chore: publish artifact ${name} ${version}`, ignoreFiles: '.npmignore'})

const registry = env.NPM_REGISTRY || 'https://registry.npmjs.org'
const npmrc = path.resolve(cwd, '.npmrc')
console.log(`publish npm package to ${registry}`)
await $`npm publish --no-git-tag-version --registry=${registry}`

await $.raw`echo ${registry.replace(/https?:/, '')}/:_authToken=${$.env.NPM_TOKEN} >> ${npmrc}`
await $`npm publish --no-git-tag-version --registry=${registry} --userconfig ${npmrc} --no-workspaces`
})

export const getArtifactPath = (tag) => tag.toLowerCase().replace(/[^a-z0-9-]/g, '-')
Expand Down
7 changes: 2 additions & 5 deletions src/test/js/test-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,10 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url))
export const fixtures = path.resolve(__dirname, '../fixtures')

export const createNpmRegistry = () => {
const VERDACCIO_TOKEN = 'mRv6eIuiaggXGb9ZDFCtBA=='
$.cwd = path.resolve(__dirname, '../../../')
$.raw`echo "//localhost:4873/:_authToken=${VERDACCIO_TOKEN}" >> .npmrc`

let p

return {
address: 'http://localhost:4873/',
address: $.env.NPM_REGISTRY,
async start() {
fs.removeSync(path.resolve(__dirname, '../../../storage'))
const config = path.resolve(__dirname, '../../../verdaccio.config.yaml')
Expand Down

0 comments on commit 77870b9

Please sign in to comment.