-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Support workspaces in destination (#101)
- Loading branch information
Showing
37 changed files
with
630 additions
and
165 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,5 @@ | ||
--- | ||
"secco": patch | ||
--- | ||
|
||
Correctly display additional information e.g. during `npm install` when `VERBOSE` env var is set |
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,5 @@ | ||
--- | ||
"secco": minor | ||
--- | ||
|
||
Add `SECCO_VERDACCIO_PORT` environment variable. You can use this to change the default port (`4873`) when secco uses Verdaccio. |
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,7 @@ | ||
--- | ||
"secco": minor | ||
--- | ||
|
||
You can now use secco inside destinations that are set up with [workspaces](https://docs.npmjs.com/cli/v10/using-npm/workspaces). It should work for all supported package managers (npm, yarn, pnpm, bun). | ||
|
||
Please note: secco will automatically use the `--force-verdaccio` flag when inside a workspaces project. |
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
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
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 was deleted.
Oops, something went wrong.
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,87 @@ | ||
import fs from 'fs-extra' | ||
import { join } from 'pathe' | ||
import type { Application } from '../models/application' | ||
import { presets } from '../presets' | ||
|
||
async function renamePnpmWorkspaceFixture(app: Application) { | ||
const fixture = join(app.dir, 'destination', 'fixture.pnpm-workspace.yaml') | ||
const tmpWorkspaceYaml = join(app.dir, 'destination', 'pnpm-workspace.yaml') | ||
|
||
await fs.rename(fixture, tmpWorkspaceYaml) | ||
} | ||
|
||
describe.sequential('scan-once', () => { | ||
describe.sequential('single package', () => { | ||
let app: Application | ||
|
||
beforeAll(async () => { | ||
app = await presets.kitchenSink.commit() | ||
|
||
process.env.SECCO_VERDACCIO_PORT = '4873' | ||
}) | ||
|
||
afterAll(async () => { | ||
await app.cleanup() | ||
}) | ||
|
||
it('should run Verdaccio with --force-verdaccio', () => { | ||
const [exitCode, logs] = app.cli(['--scan-once', '--force-verdaccio', '--verbose']) | ||
|
||
logs.should.contain('[log] [Verdaccio] Starting server...') | ||
logs.should.contain('[log] [Verdaccio] Started successfully!') | ||
logs.should.contain('[log] Publishing `say-hello-world@0.0.2-secco-') | ||
logs.should.contain('[log] Published `say-hello-world@0.0.2-secco-') | ||
logs.should.contain(`[debug] Detected package manager in destination: ${app.packageManager.split('@')[0]}`) | ||
logs.should.contain('[log] Installing packages from local registry:') | ||
logs.should.contain('[success] Installation finished successfully!') | ||
|
||
expect(exitCode).toBe(0) | ||
}) | ||
|
||
it('should copy files on consecutive runs', () => { | ||
const [exitCode, logs] = app.cli(['--scan-once'], { verbose: true }) | ||
|
||
logs.should.not.contain('[log] [Verdaccio] Starting server...') | ||
logs.should.not.contain('[success] Installation finished successfully!') | ||
logs.should.contain('[log] Copied `index.mjs` to `node_modules/say-hello-world/index.mjs`') | ||
logs.should.contain('[log] Copied `package.json` to `node_modules/say-hello-world/package.json`') | ||
logs.should.contain('[info] Copied 2 files. Exiting...') | ||
|
||
expect(exitCode).toBe(0) | ||
}) | ||
}) | ||
|
||
describe.sequential('workspaces', () => { | ||
let app: Application | ||
|
||
beforeAll(async () => { | ||
app = await presets.kitchenSinkWorkspaces.commit() | ||
|
||
if (process.env.INTEGRATION_PM_NAME === 'pnpm') { | ||
await renamePnpmWorkspaceFixture(app) | ||
} | ||
|
||
process.env.SECCO_VERDACCIO_PORT = '4874' | ||
}) | ||
|
||
afterAll(async () => { | ||
await app.cleanup() | ||
}) | ||
|
||
it('should work (with Verdaccio by default)', () => { | ||
const [exitCode, logs] = app.cli(['--scan-once'], { verbose: true }) | ||
|
||
logs.logOutput() | ||
|
||
logs.should.contain('[log] [Verdaccio] Starting server...') | ||
logs.should.contain('[log] [Verdaccio] Started successfully!') | ||
logs.should.contain('[log] Publishing `say-hello-world-workspaces@1.0.0-secco-') | ||
logs.should.contain('[log] Published `say-hello-world-workspaces@1.0.0-secco-') | ||
logs.should.contain(`[debug] Detected package manager in destination: ${app.packageManager.split('@')[0]}`) | ||
logs.should.contain('[log] Installing packages from local registry:') | ||
logs.should.contain('[success] Installation finished successfully!') | ||
|
||
expect(exitCode).toBe(0) | ||
}) | ||
}) | ||
}) |
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
2 changes: 2 additions & 0 deletions
2
integration/fixtures/kitchen-sink-workspaces/destination/fixture.pnpm-workspace.yaml
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,2 @@ | ||
packages: | ||
- 'packages/*' |
7 changes: 7 additions & 0 deletions
7
integration/fixtures/kitchen-sink-workspaces/destination/package.json
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,7 @@ | ||
{ | ||
"name": "kitchen-sink-workspaces-destination", | ||
"private": true, | ||
"workspaces": [ | ||
"packages/*" | ||
] | ||
} |
7 changes: 7 additions & 0 deletions
7
...tion/fixtures/kitchen-sink-workspaces/destination/packages/destination-workspaces/bin.mjs
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,7 @@ | ||
import { sayHelloWorld } from 'say-hello-world' | ||
|
||
function run() { | ||
sayHelloWorld() | ||
} | ||
|
||
run() |
12 changes: 12 additions & 0 deletions
12
...fixtures/kitchen-sink-workspaces/destination/packages/destination-workspaces/package.json
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,12 @@ | ||
{ | ||
"name": "destination-workspaces", | ||
"version": "1.0.0", | ||
"private": true, | ||
"main": "bin.mjs", | ||
"scripts": { | ||
"start": "node bin.mjs" | ||
}, | ||
"dependencies": { | ||
"say-hello-world-workspaces": "^1.0.0" | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
integration/fixtures/kitchen-sink-workspaces/source/package.json
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,5 @@ | ||
{ | ||
"name": "kitchen-sink-workspaces-source", | ||
"private": true, | ||
"packageManager": "pnpm@9.4.0" | ||
} |
7 changes: 7 additions & 0 deletions
7
...ion/fixtures/kitchen-sink-workspaces/source/packages/say-hello-world-workspaces/index.mjs
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,7 @@ | ||
function sayHelloWorld() { | ||
// eslint-disable-next-line no-console | ||
console.log('Hello World!') | ||
} | ||
export { | ||
sayHelloWorld, | ||
} |
6 changes: 6 additions & 0 deletions
6
.../fixtures/kitchen-sink-workspaces/source/packages/say-hello-world-workspaces/package.json
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,6 @@ | ||
{ | ||
"name": "say-hello-world-workspaces", | ||
"version": "1.0.0", | ||
"packageManager": "pnpm@9.4.0", | ||
"main": "index.mjs" | ||
} |
2 changes: 2 additions & 0 deletions
2
integration/fixtures/kitchen-sink-workspaces/source/pnpm-workspace.yaml
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,2 @@ | ||
packages: | ||
- 'packages/*' |
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
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
Oops, something went wrong.