-
Notifications
You must be signed in to change notification settings - Fork 23
feat: add workspace support #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
a507437
feat: add workspace support
fritzy 055e18b
use @npmcli/fs instead of fs/promise
fritzy 712db0b
cleanup based on feedback
fritzy 2aa3b44
Merge branch 'fritzy/workspaces' of github.com:npm/template-oss into …
fritzy 7d16cfe
updated config options to be more granular
fritzy 7c89c83
updated config options to be more granular
fritzy 4f51f43
Merge branch 'fritzy/workspaces' of github.com:npm/template-oss into …
fritzy 1aafd77
fixes after applying to the npm cli
fritzy c24ae4c
pkg.templateVersion to pkg.templateOSS.version
fritzy 3088050
removed LICENSE.md content
fritzy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,48 @@ | ||
| const PackageJson = require('@npmcli/package-json') | ||
| const mapWorkspaces = require('@npmcli/map-workspaces') | ||
|
|
||
| const defaultConfig = { | ||
| applyRootRepoFiles: true, | ||
| applyWorkspaceRepoFiles: true, | ||
| applyRootModuleFiles: true, | ||
| workspaces: [], | ||
| paths: [], | ||
| } | ||
|
|
||
| module.exports = async (root) => { | ||
| let pkg | ||
| let pkgError = false | ||
| try { | ||
| pkg = (await PackageJson.load(root)).content | ||
| } catch (e) { | ||
| pkgError = true | ||
| } | ||
| if (pkgError || !pkg.templateOSS) { | ||
| return { | ||
| ...defaultConfig, | ||
| paths: [root], | ||
| } | ||
| } | ||
| const config = { | ||
| ...defaultConfig, | ||
| ...pkg.templateOSS, | ||
| } | ||
| const workspaceMap = await mapWorkspaces({ | ||
| pkg, | ||
| cwd: root, | ||
| }) | ||
| const wsPaths = [] | ||
| const workspaceSet = new Set(config.workspaces) | ||
| for (const [name, path] of workspaceMap.entries()) { | ||
| if (workspaceSet.has(name)) { | ||
| wsPaths.push(path) | ||
| } | ||
| } | ||
| config.workspacePaths = wsPaths | ||
|
|
||
| config.paths = config.paths.concat(config.workspacePaths) | ||
|
|
||
| config.paths.push(root) | ||
|
|
||
| return config | ||
| } |
This file contains hidden or 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,76 @@ | ||
| name: Node Workspace CI %%pkgname%% | ||
|
|
||
| on: | ||
| pull_request: | ||
| paths: | ||
| - %%pkgpath%%/** | ||
| branches: | ||
| - '*' | ||
| push: | ||
| paths: | ||
| - %%pkgpath%%/** | ||
| branches: | ||
| - release-next | ||
| - latest | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| lint: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| # Checkout the npm/cli repo | ||
| - uses: actions/checkout@v2 | ||
| - name: Use Node.js 16.x | ||
| uses: actions/setup-node@v2 | ||
| with: | ||
| node-version: 16.x | ||
| cache: npm | ||
| - name: Install dependencies | ||
| run: | | ||
| node ./bin/npm-cli.js install --ignore-scripts --no-audit | ||
| node ./bin/npm-cli.js rebuild | ||
| - name: Run linting | ||
| run: node ./bin/npm-cli.js run posttest -w libnpmdiff | ||
| env: | ||
| DEPLOY_VERSION: testing | ||
|
|
||
| test: | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| node-version: ['12.13.0', 12.x, '14.15.0', 14.x, '16.0.0', 16.x] | ||
| platform: | ||
| - os: ubuntu-latest | ||
| shell: bash | ||
| - os: macos-latest | ||
| shell: bash | ||
| - os: windows-latest | ||
| shell: bash | ||
| - os: windows-latest | ||
| shell: powershell | ||
|
|
||
| runs-on: ${{ matrix.platform.os }} | ||
| defaults: | ||
| run: | ||
| shell: ${{ matrix.platform.shell }} | ||
|
|
||
| steps: | ||
| # Checkout the npm/cli repo | ||
| - uses: actions/checkout@v2 | ||
|
|
||
| # Installs the specific version of Node.js | ||
| - name: Use Node.js ${{ matrix.node-version }} | ||
| uses: actions/setup-node@v2 | ||
| with: | ||
| node-version: ${{ matrix.node-version }} | ||
| cache: npm | ||
|
|
||
| # Run the installer script | ||
| - name: Install dependencies | ||
| run: | | ||
| node ./bin/npm-cli.js install --ignore-scripts --no-audit | ||
| node ./bin/npm-cli.js rebuild | ||
|
|
||
| # Run the tests, but not if we're just gonna do coveralls later anyway | ||
| - name: Run Tap tests | ||
| run: node ./bin/npm-cli.js run -w libnpmdiff --ignore-scripts test -- -t600 -Rbase -c |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.