Skip to content

Commit

Permalink
Sm/linked-plugin-compile (#517)
Browse files Browse the repository at this point in the history
* chore: dedupe lockfile, bump deps

* chore: vscode settings and debugger

* style: typos

* chore: bump oclif/core

* fix: compile ts plugins during linking

* chore: ignore and remove vscode settings

* fix: check ts on plugin, not root

* fix: better cwd

* fix: oclif's yarn.exec adds unnecessary props when `run` isn't the first arg

* chore: add shx for x-platform development

Co-authored-by: Rodrigo Espinosa de los Monteros <[email protected]>
  • Loading branch information
mshanemc and RodEsp authored Jan 6, 2023
1 parent d86310c commit 0ffd8de
Show file tree
Hide file tree
Showing 9 changed files with 348 additions and 239 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
*-debug.log
*-error.log
.oclif.manifest.json
.vscode/settings.json
/.nyc_output
/coverage
/coverage.lcov
Expand Down
46 changes: 46 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "Attach",
"port": 9229,
"skipFiles": ["<node_internals>/**"]
},
{
"name": "Run All Tests",
"type": "node",
"request": "launch",
"protocol": "inspector",
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
"args": ["--inspect", "--no-timeouts", "--colors", "test/**/*.test.ts"],
"env": {
"NODE_ENV": "development",
"SFDX_ENV": "development"
},
"sourceMaps": true,
"smartStep": true,
"internalConsoleOptions": "openOnSessionStart",
"preLaunchTask": "Compile"
},
{
"type": "node",
"request": "launch",
"name": "Run Current Test",
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
"args": ["--inspect", "--no-timeouts", "--colors", "${file}"],
"env": {
"NODE_ENV": "development",
"SFDX_ENV": "development"
},
"sourceMaps": true,
"smartStep": true,
"internalConsoleOptions": "openOnSessionStart",
"preLaunchTask": "Compile"
}
]
}
57 changes: 57 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"version": "2.0.0",
"problemMatcher": "$tsc-watch",
"tasks": [
{
"label": "Compile",
"group": {
"kind": "build",
"isDefault": true
},
"command": "yarn",
"type": "shell",
"presentation": {
"focus": false,
"panel": "dedicated"
},
"args": ["run", "prepack"],
"isBackground": false,
"problemMatcher": {
"owner": "typescript",
"fileLocation": "relative",
"pattern": {
"regexp": "^(.*\\.ts):(\\d*):(\\d*)(\\s*-\\s*)(error|warning|info)\\s*(TS\\d*):\\s*(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 5,
"code": 6,
"message": 7
}
}
},
{
"label": "Lint",
"command": "yarn",
"type": "shell",
"presentation": {
"focus": false,
"panel": "dedicated"
},
"args": ["run", "lint"],
"isBackground": false,
"problemMatcher": {
"owner": "typescript",
"fileLocation": "relative",
"pattern": {
"regexp": "^(ERROR|WARNING|INFO):\\s*(.*\\.ts):(\\d*):(\\d*)(\\s*-\\s*)(.*)$",
"file": 2,
"line": 3,
"column": 4,
"severity": 1,
"message": 6
}
}
}
]
}
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"mocha": "^9.2.2",
"nock": "^13.2.4",
"oclif": "^2.6.3",
"shx": "^0.3.4",
"ts-node": "^10.7.0",
"typescript": "4.9.4"
},
Expand Down Expand Up @@ -70,9 +71,9 @@
},
"repository": "oclif/plugin-plugins",
"scripts": {
"build": "rm -rf lib && tsc",
"build": "shx rm -rf lib && tsc",
"commitlint": "commitlint",
"clean": "rm -f oclif.manifest.json",
"clean": "shx rm -f oclif.manifest.json",
"lint": "eslint . --ext .ts --config .eslintrc",
"pretest": "yarn build && tsc -p test --noEmit",
"test": "mocha --forbid-only \"test/**/*.test.ts\"",
Expand All @@ -83,4 +84,4 @@
"version": "oclif readme && git add README.md"
},
"types": "lib/index.d.ts"
}
}
6 changes: 3 additions & 3 deletions src/commands/plugins/inspect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import {sortBy} from '../../util'

function trimUntil(fsPath: string, part: string): string {
const parts = fsPath.split(path.sep)
const indicies = parts.reduce((a, e, i) => (e === part) ? a.concat([i]) : a, [] as number[])
const partIndex = Math.max(...indicies)
const indices = parts.reduce((a, e, i) => (e === part) ? a.concat([i]) : a, [] as number[])
const partIndex = Math.max(...indices)
if (partIndex === -1) return fsPath
return parts.slice(0, partIndex + 1).join(path.sep)
}
Expand Down Expand Up @@ -37,7 +37,7 @@ export default class PluginsInspect extends Command {
plugins = new Plugins(this.config);

// In this case we want these operations to happen
// sequentially so the `no-await-in-loop` rule is ugnored
// sequentially so the `no-await-in-loop` rule is ignored
/* eslint-disable no-await-in-loop */
async run(): Promise<void> {
const {flags, argv} = await this.parse(PluginsInspect)
Expand Down
2 changes: 1 addition & 1 deletion src/commands/plugins/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ e.g. If you have a core plugin that has a 'hello' command, installing a user-ins
plugins = new Plugins(this.config);

// In this case we want these operations to happen
// sequentially so the `no-await-in-loop` rule is ugnored
// sequentially so the `no-await-in-loop` rule is ignored
/* eslint-disable no-await-in-loop */
async run(): Promise<void> {
const {flags, argv} = await this.parse(PluginsInstall)
Expand Down
2 changes: 1 addition & 1 deletion src/commands/plugins/uninstall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default class PluginsUninstall extends Command {
plugins = new Plugins(this.config)

// In this case we want these operations to happen
// sequentially so the `no-await-in-loop` rule is ugnored
// sequentially so the `no-await-in-loop` rule is ignored
/* eslint-disable no-await-in-loop */
async run(): Promise<void> {
const {flags, argv} = await this.parse(PluginsUninstall)
Expand Down
Loading

0 comments on commit 0ffd8de

Please sign in to comment.