Skip to content

Commit 160ed86

Browse files
committed
chore: reorganize scripts in package.json
- polish package.json and related assets - remove unused scripts - add build:production script - add package script and pre-package scripts as infra - add vsce package as devDependencies
1 parent 58f7cb7 commit 160ed86

27 files changed

Lines changed: 1421 additions & 383 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,6 @@ coverage
88
e2e/logs
99
samples/**/logs
1010
**/.turbo
11+
packages/vscode-webdriverio/README.md
12+
packages/vscode-webdriverio/CHANGELOG.md
13+
packages/vscode-webdriverio/LICENSE

.husky/pre-push

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pnpm run test:unit

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"name": "Run Extension",
1010
"type": "extensionHost",
1111
"request": "launch",
12-
"args": ["--extensionDevelopmentPath=${workspaceFolder}"],
12+
"args": ["--extensionDevelopmentPath=${workspaceFolder}/packages/vscode-webdriverio"],
1313
"outFiles": ["${workspaceFolder}/packages/vscode-webdriverio/dist/*.cjs"],
1414
"preLaunchTask": "${defaultBuildTask}"
1515
}

.vscode/tasks.json

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,13 @@
4040
},
4141
{
4242
"type": "npm",
43-
"script": "watch-tests",
44-
"problemMatcher": "$tsc-watch",
43+
"script": "watch:test",
4544
"isBackground": true,
4645
"presentation": {
4746
"reveal": "never",
4847
"group": "watchers"
4948
},
5049
"group": "build"
51-
},
52-
{
53-
"label": "tasks: watch-tests",
54-
"dependsOn": ["npm: watch", "npm: watch-tests"],
55-
"problemMatcher": []
5650
}
5751
]
5852
}

e2e/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
}
1111
},
1212
"scripts": {
13-
"test:e2e": "npm-run-all test:e2e:*",
13+
"test:e2e": "run-s test:e2e:*",
1414
"test:e2e:mocha": "cross-env VSCODE_WDIO_E2E_FRAMEWORK=mocha xvfb-maybe pnpm run wdio",
1515
"test:e2e:jasmine": "cross-env VSCODE_WDIO_E2E_FRAMEWORK=jasmine xvfb-maybe pnpm run wdio",
1616
"test:e2e:cucumber": "cross-env VSCODE_WDIO_E2E_FRAMEWORK=cucumber xvfb-maybe pnpm run wdio",

e2e/wdio.conf.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ export const config: WebdriverIO.Config = {
1515
browserVersion: 'stable', // also possible: "insiders" or a specific version e.g. "1.80.0"
1616
'wdio:vscodeOptions': {
1717
// points to directory where extension package.json is located
18-
extensionPath: path.resolve('..'),
18+
extensionPath: path.resolve('../packages/vscode-webdriverio'),
1919
// optional VS Code settings
2020
userSettings: {
2121
'webdriverio.logLevel': 'trace',
2222
},
23-
workspacePath: path.resolve(path.join('..', 'samples', 'e2e', target)),
23+
workspacePath: path.resolve(`../samples/e2e/${target}`),
2424
},
2525
'wdio:enforceWebDriverClassic': true,
2626
},

infra/pre-package/package.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name": "@vscode-wdio/pre-package",
3+
"private": true,
4+
"type": "module",
5+
"scripts": {
6+
"copy": "tsx ./src/copy.ts"
7+
},
8+
"dependencies": {}
9+
}

infra/pre-package/src/copy.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import path from 'node:path'
2+
import url from 'node:url'
3+
4+
import shell from 'shelljs'
5+
6+
const __dirname = path.dirname(url.fileURLToPath(import.meta.url))
7+
const rootDir = path.resolve(__dirname, '..', '..', '..')
8+
const targetFiles = [
9+
path.resolve(rootDir, 'README.md'),
10+
path.resolve(rootDir, 'CHANGELOG.md'),
11+
path.resolve(rootDir, 'LICENSE'),
12+
]
13+
const destDir = path.resolve(rootDir, 'packages/vscode-webdriverio')
14+
15+
const result = shell.cp('-f', targetFiles, destDir)
16+
17+
if (result.stdout) {
18+
console.log(result.stdout)
19+
}
20+
if (result.stderr) {
21+
console.error(result.stderr)
22+
}
23+
if (result.code === 0) {
24+
console.log(
25+
`All files were copied: \n${targetFiles
26+
.map((file) => {
27+
const from = path.relative(rootDir, file)
28+
const to = path.relative(rootDir, `${destDir}/${path.basename(file)}`)
29+
return ` ${from} -> ${to}`
30+
})
31+
.join('\n')}`
32+
)
33+
}
34+
process.exit(result.code)

package.json

Lines changed: 7 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -4,95 +4,17 @@
44
"description": "WebdriverIO for the vscode",
55
"version": "0.0.1",
66
"type": "module",
7+
"private": true,
78
"author": "WebdriverIO Team",
89
"packageManager": "[email protected]",
910
"license": "MIT",
10-
"repository": {
11-
"type": "git",
12-
"url": "https://github.com/webdriverio/vscode-webdriverio.git"
13-
},
14-
"bugs": {
15-
"url": "https://github.com/webdriverio/vscode-webdriverio/issues"
16-
},
17-
"keywords": [
18-
"WebdriverIO",
19-
"test",
20-
"typescript",
21-
"javascript"
22-
],
23-
"categories": [
24-
"Testing"
25-
],
26-
"engines": {
27-
"vscode": "^1.98.0"
28-
},
29-
"activationEvents": [
30-
"onLanguage:javascript",
31-
"onLanguage:typescript",
32-
"workspaceContains:**/wdio.conf.js",
33-
"workspaceContains:**/wdio.conf.ts"
34-
],
3511
"main": "./packages/vscode-webdriverio/dist/extension.cjs",
36-
"contributes": {
37-
"commands": [
38-
{
39-
"command": "webdriverio.configureTests",
40-
"title": "WebdriverIO: Configure Tests"
41-
}
42-
],
43-
"viewsContainers": {
44-
"activitybar": [
45-
{
46-
"id": "webdriverio-explorer",
47-
"title": "WebdriverIO Explorer",
48-
"icon": "media/icon.svg"
49-
}
50-
]
51-
},
52-
"configuration": {
53-
"title": "WebdriverIO",
54-
"properties": {
55-
"webdriverio.nodeExecutable": {
56-
"markdownDescription": "The path to the Node.js executable. If not assigned, WebdriverIO just passes down `'node'` to `child_process.spawn`.",
57-
"type": "string"
58-
},
59-
"webdriverio.configFilePattern": {
60-
"type": "array",
61-
"items": {
62-
"type": "string"
63-
},
64-
"default": [
65-
"**/wdio.conf.{ts,js}"
66-
],
67-
"description": "Glob pattern for WebdriverIO configuration file"
68-
},
69-
"webdriverio.logLevel": {
70-
"type": "string",
71-
"enum": [
72-
"trace",
73-
"debug",
74-
"info",
75-
"warn",
76-
"error",
77-
"silent"
78-
],
79-
"default": "info",
80-
"description": "Set the logLevel"
81-
},
82-
"webdriverio.showOutput": {
83-
"type": "boolean",
84-
"default": true,
85-
"description": "Show WebdriverIO output in the test result"
86-
}
87-
}
88-
}
89-
},
9012
"scripts": {
9113
"vscode:prepublish": "pnpm run package",
9214
"compile": "turbo run typecheck build --filter=./packages/*",
9315
"build": "turbo run build --filter=./packages/*",
9416
"typecheck": "turbo run typecheck --filter=./packages/*",
95-
"watch": "npm-run-all -p watch:*",
17+
"watch": "run-p watch:*",
9618
"watch:build": "turbo watch build --filter=./packages/*",
9719
"watch:typecheck": "turbo watch typecheck --filter=./packages/*",
9820
"watch:test": "vitest",
@@ -101,10 +23,13 @@
10123
"format:fix": "prettier --write .",
10224
"lint": "eslint .",
10325
"lint:fix": "eslint --fix .",
104-
"test:e2e": "pnpm --filter @vscode-wdio/e2e run test:e2e",
26+
"test": "run-s test:*",
10527
"test:unit": "vitest --run",
28+
"test:e2e": "pnpm --filter @vscode-wdio/e2e run test:e2e",
10629
"coverage": "vitest --run --coverage",
107-
"graph": "pnpm run build --graph assets/build.png"
30+
"graph": "pnpm run build --graph assets/build.png",
31+
"postinstall": "run-s postinstall:*",
32+
"postinstall:husky": "husky"
10833
},
10934
"devDependencies": {
11035
"@types/node": "20.x",

packages/vscode-wdio-api/package.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,10 @@
99
}
1010
},
1111
"scripts": {
12-
"build-production": "npm run clean-build",
1312
"build": "tsc -p .",
13+
"build:production": "pnpm clean && pnpm run build",
1414
"typecheck": "tsc --noEmit --project tsconfig.json",
15-
"clean-build": "npm run clean && npm run build",
16-
"clean": "shx rm -rf out dist coverage",
17-
"test": "vitest run .",
18-
"watch": "tsc -p . --watch"
15+
"clean": "shx rm -rf out dist coverage"
1916
},
2017
"dependencies": {
2118
"@vscode-wdio/constants": "workspace:*",

0 commit comments

Comments
 (0)