Skip to content

Commit

Permalink
chore: move mock-globals to its own workspace (#6474)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: Gar <gar+gh@danger.computer>
  • Loading branch information
lukekarrys and wraithgar committed May 19, 2023
1 parent 37cc797 commit e71010a
Show file tree
Hide file tree
Showing 30 changed files with 244 additions and 20 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module.exports = {
ignorePatterns: [
'docs/**',
'smoke-tests/**',
'mock-globals/**',
'mock-registry/**',
'workspaces/**',
],
Expand Down
94 changes: 94 additions & 0 deletions .github/workflows/ci-npmcli-mock-globals.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# This file is automatically added by @npmcli/template-oss. Do not edit.

name: CI - @npmcli/mock-globals

on:
workflow_dispatch:
pull_request:
paths:
- mock-globals/**
push:
branches:
- main
- latest
paths:
- mock-globals/**
schedule:
# "At 09:00 UTC (02:00 PT) on Monday" https://crontab.guru/#0_9_*_*_1
- cron: "0 9 * * 1"

jobs:
lint:
name: Lint
if: github.repository_owner == 'npm'
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Git User
run: |
git config --global user.email "npm-cli+bot@github.com"
git config --global user.name "npm CLI robot"
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: npm
- name: Reset Deps
run: node . run resetdeps
- name: Lint
run: node . run lint --ignore-scripts -w @npmcli/mock-globals
- name: Post Lint
run: node . run postlint --ignore-scripts -w @npmcli/mock-globals

test:
name: Test - ${{ matrix.platform.name }} - ${{ matrix.node-version }}
if: github.repository_owner == 'npm'
strategy:
fail-fast: false
matrix:
platform:
- name: Linux
os: ubuntu-latest
shell: bash
- name: macOS
os: macos-latest
shell: bash
- name: Windows
os: windows-latest
shell: cmd
node-version:
- 14.17.0
- 14.x
- 16.13.0
- 16.x
- 18.0.0
- 18.x
runs-on: ${{ matrix.platform.os }}
defaults:
run:
shell: ${{ matrix.platform.shell }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Git User
run: |
git config --global user.email "npm-cli+bot@github.com"
git config --global user.name "npm CLI robot"
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: npm
- name: Reset Deps
run: node . run resetdeps
- name: Add Problem Matcher
run: echo "::add-matcher::.github/matchers/tap.json"
- name: Test
run: node . test --ignore-scripts -w @npmcli/mock-globals
- name: Check Git Status
if: matrix && matrix.platform.os != 'windows-latest'
run: node scripts/git-dirty.js
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
paths-ignore:
- docs/**
- smoke-tests/**
- mock-globals/**
- mock-registry/**
- workspaces/**
push:
Expand All @@ -17,6 +18,7 @@ on:
paths-ignore:
- docs/**
- smoke-tests/**
- mock-globals/**
- mock-registry/**
- workspaces/**
schedule:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
!/test/
!/docs/
!/smoke-tests/
!/mock-globals/
!/mock-registry/
!/workspaces/
/workspaces/*
Expand Down
11 changes: 10 additions & 1 deletion DEPENDENCIES.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ graph LR;
libnpmpublish-->npm-package-arg;
libnpmpublish-->npm-registry-fetch;
libnpmpublish-->npmcli-eslint-config["@npmcli/eslint-config"];
libnpmpublish-->npmcli-mock-globals["@npmcli/mock-globals"];
libnpmpublish-->npmcli-mock-registry["@npmcli/mock-registry"];
libnpmpublish-->npmcli-template-oss["@npmcli/template-oss"];
libnpmpublish-->proc-log;
Expand Down Expand Up @@ -121,6 +122,7 @@ graph LR;
npm-->npmcli-fs["@npmcli/fs"];
npm-->npmcli-git["@npmcli/git"];
npm-->npmcli-map-workspaces["@npmcli/map-workspaces"];
npm-->npmcli-mock-globals["@npmcli/mock-globals"];
npm-->npmcli-mock-registry["@npmcli/mock-registry"];
npm-->npmcli-package-json["@npmcli/package-json"];
npm-->npmcli-promise-spawn["@npmcli/promise-spawn"];
Expand Down Expand Up @@ -208,6 +210,8 @@ graph LR;
npmcli-metavuln-calculator-->json-parse-even-better-errors;
npmcli-metavuln-calculator-->pacote;
npmcli-metavuln-calculator-->semver;
npmcli-mock-globals-->npmcli-eslint-config["@npmcli/eslint-config"];
npmcli-mock-globals-->npmcli-template-oss["@npmcli/template-oss"];
npmcli-mock-registry-->npm-package-arg;
npmcli-mock-registry-->npmcli-arborist["@npmcli/arborist"];
npmcli-mock-registry-->npmcli-eslint-config["@npmcli/eslint-config"];
Expand Down Expand Up @@ -424,6 +428,7 @@ graph LR;
libnpmpublish-->npm-package-arg;
libnpmpublish-->npm-registry-fetch;
libnpmpublish-->npmcli-eslint-config["@npmcli/eslint-config"];
libnpmpublish-->npmcli-mock-globals["@npmcli/mock-globals"];
libnpmpublish-->npmcli-mock-registry["@npmcli/mock-registry"];
libnpmpublish-->npmcli-template-oss["@npmcli/template-oss"];
libnpmpublish-->proc-log;
Expand Down Expand Up @@ -550,6 +555,7 @@ graph LR;
npm-->npmcli-fs["@npmcli/fs"];
npm-->npmcli-git["@npmcli/git"];
npm-->npmcli-map-workspaces["@npmcli/map-workspaces"];
npm-->npmcli-mock-globals["@npmcli/mock-globals"];
npm-->npmcli-mock-registry["@npmcli/mock-registry"];
npm-->npmcli-package-json["@npmcli/package-json"];
npm-->npmcli-promise-spawn["@npmcli/promise-spawn"];
Expand Down Expand Up @@ -689,6 +695,9 @@ graph LR;
npmcli-metavuln-calculator-->json-parse-even-better-errors;
npmcli-metavuln-calculator-->pacote;
npmcli-metavuln-calculator-->semver;
npmcli-mock-globals-->npmcli-eslint-config["@npmcli/eslint-config"];
npmcli-mock-globals-->npmcli-template-oss["@npmcli/template-oss"];
npmcli-mock-globals-->tap;
npmcli-mock-registry-->nock;
npmcli-mock-registry-->npm-package-arg;
npmcli-mock-registry-->npmcli-arborist["@npmcli/arborist"];
Expand Down Expand Up @@ -826,5 +835,5 @@ packages higher up the chain.
- npm-registry-fetch, libnpmversion
- @npmcli/git, make-fetch-happen, @npmcli/config, init-package-json
- @npmcli/installed-package-contents, @npmcli/map-workspaces, cacache, npm-pick-manifest, @npmcli/run-script, read-package-json, @npmcli/package-json, promzard
- @npmcli/docs, @npmcli/fs, npm-bundled, read-package-json-fast, unique-filename, npm-install-checks, npm-package-arg, npm-packlist, normalize-package-data, bin-links, nopt, npmlog, parse-conflict-json, read
- @npmcli/docs, @npmcli/fs, npm-bundled, read-package-json-fast, unique-filename, npm-install-checks, npm-package-arg, npm-packlist, normalize-package-data, bin-links, nopt, npmlog, parse-conflict-json, @npmcli/mock-globals, read
- @npmcli/eslint-config, @npmcli/template-oss, ignore-walk, semver, npm-normalize-package-bin, @npmcli/name-from-folder, json-parse-even-better-errors, fs-minipass, ssri, unique-slug, @npmcli/promise-spawn, hosted-git-info, proc-log, validate-npm-package-name, @npmcli/node-gyp, minipass-fetch, @npmcli/query, cmd-shim, read-cmd-shim, write-file-atomic, abbrev, are-we-there-yet, gauge, minify-registry-metadata, ini, @npmcli/disparity-colors, mute-stream, npm-audit-report, npm-user-validate
17 changes: 17 additions & 0 deletions mock-globals/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/* This file is automatically added by @npmcli/template-oss. Do not edit. */

'use strict'

const { readdirSync: readdir } = require('fs')

const localConfigs = readdir(__dirname)
.filter((file) => file.startsWith('.eslintrc.local.'))
.map((file) => `./${file}`)

module.exports = {
root: true,
extends: [
'@npmcli',
...localConfigs,
],
}
21 changes: 21 additions & 0 deletions mock-globals/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# This file is automatically added by @npmcli/template-oss. Do not edit.

# ignore everything in the root
/*

# keep these
!**/.gitignore
!/.eslintrc.js
!/.eslintrc.local.*
!/.gitignore
!/bin/
!/CHANGELOG*
!/docs/
!/lib/
!/LICENSE*
!/map.js
!/package.json
!/README*
!/scripts/
!/tap-snapshots/
!/test/
File renamed without changes.
54 changes: 54 additions & 0 deletions mock-globals/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"name": "@npmcli/mock-globals",
"version": "1.0.0",
"description": "",
"main": "lib/index.js",
"private": true,
"scripts": {
"test": "tap",
"lint": "eslint \"**/*.js\"",
"postlint": "template-oss-check",
"template-oss-apply": "template-oss-apply --force",
"lintfix": "node .. run lint -- --fix",
"snap": "tap",
"posttest": "node .. run lint"
},
"repository": {
"type": "git",
"url": "https://github.com/npm/cli.git",
"directory": "mock-globals"
},
"keywords": [],
"author": "GitHub Inc.",
"license": "ISC",
"bugs": {
"url": "https://github.com/npm/cli/issues"
},
"homepage": "https://github.com/npm/cli#readme",
"files": [
"bin/",
"lib/"
],
"engines": {
"node": "^14.17.0 || ^16.13.0 || >=18.0.0"
},
"templateOSS": {
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
"version": "4.14.1"
},
"tap": {
"branches": 89,
"functions": 97,
"lines": 97,
"statements": 97,
"nyc-arg": [
"--exclude",
"tap-snapshots/**"
]
},
"devDependencies": {
"@npmcli/eslint-config": "^4.0.1",
"@npmcli/template-oss": "4.14.1",
"tap": "^16.3.2"
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const t = require('tap')
const mockGlobals = require('../../fixtures/mock-globals')
const mockGlobals = require('..')

/* eslint-disable no-console */
const originals = {
Expand Down
20 changes: 20 additions & 0 deletions package-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
"workspaces": [
"docs",
"smoke-tests",
"mock-globals",
"mock-registry",
"workspaces/*"
],
Expand Down Expand Up @@ -161,6 +162,7 @@
"@npmcli/eslint-config": "^4.0.0",
"@npmcli/fs": "^3.1.0",
"@npmcli/git": "^4.0.4",
"@npmcli/mock-globals": "^1.0.0",
"@npmcli/mock-registry": "^1.0.0",
"@npmcli/promise-spawn": "^6.0.2",
"@npmcli/template-oss": "4.14.1",
Expand Down Expand Up @@ -203,6 +205,19 @@
"node": "^14.17.0 || ^16.13.0 || >=18.0.0"
}
},
"mock-globals": {
"name": "@npmcli/mock-globals",
"version": "1.0.0",
"license": "ISC",
"devDependencies": {
"@npmcli/eslint-config": "^4.0.1",
"@npmcli/template-oss": "4.14.1",
"tap": "^16.3.2"
},
"engines": {
"node": "^14.17.0 || ^16.13.0 || >=18.0.0"
}
},
"mock-registry": {
"name": "@npmcli/mock-registry",
"version": "1.0.0",
Expand Down Expand Up @@ -2277,6 +2292,10 @@
"node": "^14.17.0 || ^16.13.0 || >=18.0.0"
}
},
"node_modules/@npmcli/mock-globals": {
"resolved": "mock-globals",
"link": true
},
"node_modules/@npmcli/mock-registry": {
"resolved": "mock-registry",
"link": true
Expand Down Expand Up @@ -15736,6 +15755,7 @@
},
"devDependencies": {
"@npmcli/eslint-config": "^4.0.0",
"@npmcli/mock-globals": "^1.0.0",
"@npmcli/mock-registry": "^1.0.0",
"@npmcli/template-oss": "4.14.1",
"lodash.clonedeep": "^4.5.0",
Expand Down
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"workspaces": [
"docs",
"smoke-tests",
"mock-globals",
"mock-registry",
"workspaces/*"
],
Expand Down Expand Up @@ -194,6 +195,7 @@
"@npmcli/eslint-config": "^4.0.0",
"@npmcli/fs": "^3.1.0",
"@npmcli/git": "^4.0.4",
"@npmcli/mock-globals": "^1.0.0",
"@npmcli/mock-registry": "^1.0.0",
"@npmcli/promise-spawn": "^6.0.2",
"@npmcli/template-oss": "4.14.1",
Expand Down Expand Up @@ -241,13 +243,15 @@
"--exclude",
"smoke-tests/**",
"--exclude",
"mock-globals/**",
"--exclude",
"mock-registry/**",
"--exclude",
"workspaces/**",
"--exclude",
"tap-snapshots/**"
],
"test-ignore": "^(docs|smoke-tests|mock-registry|workspaces)/"
"test-ignore": "^(docs|smoke-tests|mock-globals|mock-registry|workspaces)/"
},
"templateOSS": {
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
Expand Down
2 changes: 1 addition & 1 deletion test/bin/npx-cli.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const t = require('tap')
const mockGlobals = require('../fixtures/mock-globals')
const mockGlobals = require('@npmcli/mock-globals')
const tmock = require('../fixtures/tmock')

const npm = require.resolve('../../bin/npm-cli.js')
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/mock-npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const path = require('path')
const tap = require('tap')
const errorMessage = require('../../lib/utils/error-message')
const mockLogs = require('./mock-logs')
const mockGlobals = require('./mock-globals')
const mockGlobals = require('@npmcli/mock-globals')
const tmock = require('./tmock')
const defExitCode = process.exitCode

Expand Down
2 changes: 1 addition & 1 deletion test/lib/commands/adduser.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const path = require('path')
const ini = require('ini')

const { load: loadMockNpm } = require('../../fixtures/mock-npm.js')
const mockGlobals = require('../../fixtures/mock-globals.js')
const mockGlobals = require('@npmcli/mock-globals')
const MockRegistry = require('@npmcli/mock-registry')
const stream = require('stream')

Expand Down

0 comments on commit e71010a

Please sign in to comment.