-
-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add wireit to schema.json, improve consistency
- Loading branch information
Showing
13 changed files
with
88 additions
and
48 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
packages/knip/fixtures/plugins/wireit/apps/example-configuration/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,32 @@ | ||
{ | ||
"name": "@fixtures/wireit-apps-example-configuration", | ||
"version": "1.0.0", | ||
"scripts": { | ||
"build": "wireit", | ||
"bundle": "wireit" | ||
}, | ||
"wireit": { | ||
"build": { | ||
"command": "tsc", | ||
"files": [ | ||
"src/**/*.ts", | ||
"tsconfig.json" | ||
], | ||
"output": [ | ||
"lib/**" | ||
] | ||
}, | ||
"bundle": { | ||
"command": "rollup -c", | ||
"dependencies": [ | ||
"build" | ||
], | ||
"files": [ | ||
"rollup.config.json" | ||
], | ||
"output": [ | ||
"dist/bundle.js" | ||
] | ||
} | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
packages/knip/fixtures/plugins/wireit/apps/example-configuration/rollup.config.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 @@ | ||
{} |
1 change: 1 addition & 0 deletions
1
packages/knip/fixtures/plugins/wireit/apps/example-configuration/tsconfig.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 @@ | ||
{} |
21 changes: 0 additions & 21 deletions
21
packages/knip/fixtures/plugins/wireit/apps/exampleconfiguration/package.json
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
packages/knip/fixtures/plugins/wireit/apps/exampleconfiguration/rollup.config.json
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
packages/knip/fixtures/plugins/wireit/apps/exampleconfiguration/tsconfig.json
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
packages/knip/fixtures/plugins/wireit/apps/missing/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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"name": "@fixtures/wireit-apps-missing", | ||
"version": "*" | ||
"version": "1.0.0" | ||
} |
Empty file.
4 changes: 4 additions & 0 deletions
4
packages/knip/fixtures/plugins/wireit/node_modules/wireit/package.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
10 changes: 8 additions & 2 deletions
10
...ins/wireit/apps/withcommands/package.json → ...knip/fixtures/plugins/wireit/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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,53 @@ | ||
import assert from 'node:assert/strict'; | ||
import test from 'node:test'; | ||
import { main } from '../../src/index.js'; | ||
import * as wireit from '../../src/plugins/wireit/index.js'; | ||
import { resolve, join } from '../../src/util/path.js'; | ||
import baseArguments from '../helpers/baseArguments.js'; | ||
import baseCounters from '../helpers/baseCounters.js'; | ||
import { getManifest, pluginConfig as config } from '../helpers/index.js'; | ||
|
||
const wireitPath = resolve('fixtures/plugins/wireit'); | ||
|
||
async function loadWireitConfig(pathSuffix: string): Promise<string[]> { | ||
const cwd = join(wireitPath, pathSuffix); | ||
const manifestFilePath = join(cwd, 'package.json'); | ||
const manifest = getManifest(cwd); | ||
|
||
return wireit.findDependencies(manifestFilePath, { | ||
manifest, | ||
config, | ||
cwd, | ||
isProduction: false, | ||
enabledPlugins: [], | ||
}); | ||
} | ||
const cwd = resolve('fixtures/plugins/wireit'); | ||
const options = { cwd, config, isProduction: false, enabledPlugins: [] }; | ||
|
||
test('Find no dependencies when the wireit configuration is missing', async () => { | ||
const dependencies = await loadWireitConfig('apps/missing'); | ||
const dir = join(cwd, 'apps/missing'); | ||
const configFilePath = join(dir, 'package.json'); | ||
const manifest = getManifest(dir); | ||
const dependencies = await wireit.findDependencies(configFilePath, { ...options, manifest, cwd: dir }); | ||
assert.deepEqual(dependencies, []); | ||
}); | ||
|
||
test('Find dependencies when the wireit configuration has commands', async () => { | ||
const dependencies = await loadWireitConfig('apps/withcommands'); | ||
const configFilePath = join(cwd, 'package.json'); | ||
const manifest = getManifest(cwd); | ||
const dependencies = await wireit.findDependencies(configFilePath, { ...options, manifest }); | ||
assert.deepEqual(dependencies, ['bin:tsc']); | ||
}); | ||
|
||
test('Find dependencies in the example wireit configuration', async () => { | ||
const dependencies = await loadWireitConfig('apps/exampleconfiguration'); | ||
const dir = join(cwd, 'apps/example-configuration'); | ||
const configFilePath = join(dir, 'package.json'); | ||
const manifest = getManifest(dir); | ||
const dependencies = await wireit.findDependencies(configFilePath, { ...options, manifest, cwd: dir }); | ||
assert.deepEqual(dependencies, ['bin:tsc', 'bin:rollup']); | ||
}); | ||
|
||
test('Find dependencies in wireit configuration', async () => { | ||
const { issues, counters } = await main({ | ||
...baseArguments, | ||
cwd, | ||
}); | ||
|
||
assert(issues.binaries['package.json']['tsc']); | ||
assert(issues.binaries['apps/example-configuration/package.json']['rollup']); | ||
assert(issues.binaries['apps/example-configuration/package.json']['tsc']); | ||
|
||
assert.deepEqual(counters, { | ||
...baseCounters, | ||
binaries: 3, | ||
devDependencies: 0, | ||
processed: 0, | ||
total: 0, | ||
}); | ||
}); |