Skip to content

Commit

Permalink
Merge pull request #397 from oclif/mdonnalley/esm
Browse files Browse the repository at this point in the history
feat!: migrate to ESM
  • Loading branch information
WillieRuemmele authored Oct 23, 2023
2 parents 01bc4d7 + 489df1a commit b4cf7da
Show file tree
Hide file tree
Showing 36 changed files with 2,599 additions and 1,343 deletions.
3 changes: 3 additions & 0 deletions .commitlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": ["@commitlint/config-conventional"]
}
12 changes: 0 additions & 12 deletions .eslintrc

This file was deleted.

3 changes: 3 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": ["oclif", "oclif-typescript", "prettier"]
}
7 changes: 5 additions & 2 deletions .git2gus/config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
{
"productTag": "a1aB0000000ce2IIAQ",
"defaultBuild": "offcore.tooling.55",
"issueTypeLabels": { "enhancement": "USER STORY", "bug": "BUG P3" },
"defaultBuild": "offcore.tooling.59",
"issueTypeLabels": {
"enhancement": "USER STORY",
"bug": "BUG P3"
},
"hideWorkItemUrl": true,
"statusWhenClosed": "CLOSED"
}
9 changes: 6 additions & 3 deletions .github/workflows/automerge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ name: automerge
on:
workflow_dispatch:
schedule:
- cron: '17 2,5,8,11 * * *'
- cron: '42 2,5,8,11 * * *'

jobs:
automerge:
uses: oclif/github-workflows/.github/workflows/automerge.yml@main
secrets: inherit
uses: salesforcecli/github-workflows/.github/workflows/automerge.yml@main
secrets:
SVC_CLI_BOT_GITHUB_TOKEN: ${{ secrets.SVC_CLI_BOT_GITHUB_TOKEN }}
with:
mergeMethod: squash
10 changes: 8 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,11 @@ on:
workflow_dispatch:

jobs:
unit-tests:
uses: oclif/github-workflows/.github/workflows/unitTest.yml@main
yarn-lockfile-check:
uses: salesforcecli/github-workflows/.github/workflows/lockFileCheck.yml@main
linux-unit-tests:
needs: yarn-lockfile-check
uses: salesforcecli/github-workflows/.github/workflows/unitTestsLinux.yml@main
windows-unit-tests:
needs: linux-unit-tests
uses: salesforcecli/github-workflows/.github/workflows/unitTestsWindows.yml@main
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ oclif.manifest.json
yarn-error.json

.idea/*
oclif.lock
2 changes: 1 addition & 1 deletion .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname $0)/_/husky.sh"

yarn run commitlint --edit $1
yarn commitlint --edit $1
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn lint-staged --concurrent false
5 changes: 5 additions & 0 deletions .lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"*.json": ["prettier --write"],
"*.md": ["prettier --write"],
"+(src|test)/**/*.+(ts|js)": ["eslint --fix", "prettier --write"]
}
5 changes: 3 additions & 2 deletions .mocharc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"require": "ts-node/register",
"require": ["ts-node/register"],
"watch-extensions": "ts",
"recursive": true,
"reporter": "spec",
"timeout": 5000
"timeout": 5000,
"node-option": ["loader=ts-node/esm"]
}
1 change: 1 addition & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"@oclif/prettier-config"
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@oclif/plugin-command-snapshot
========
# @oclif/plugin-command-snapshot

Generates and compares OCLIF plugins snapshot files

Expand All @@ -9,12 +8,15 @@ Generates and compares OCLIF plugins snapshot files
[![License](https://img.shields.io/npm/l/@oclif/plugin-command-snapshot.svg)](https://github.com/nramyasri-sf/@oclif/plugin-command-snapshot/blob/main/package.json)

<!-- toc -->
* [Usage](#usage)
* [generates a snapshot file that has a list or commands and flags in the current CLI or plugin](#generates-a-snapshot-file-that-has-a-list-or-commands-and-flags-in-the-current-cli-or-plugin)
* [compare the current CLI or plugin commands and flags with a snapshot file to identify changes](#compare-the-current-cli-or-plugin-commands-and-flags-with-a-snapshot-file-to-identify-changes)

- [@oclif/plugin-command-snapshot](#oclifplugin-command-snapshot)
- [Usage](#usage)
- [generates a snapshot file that has a list or commands and flags in the current CLI or plugin](#generates-a-snapshot-file-that-has-a-list-or-commands-and-flags-in-the-current-cli-or-plugin)
- [compare the current CLI or plugin commands and flags with a snapshot file to identify changes](#compare-the-current-cli-or-plugin-commands-and-flags-with-a-snapshot-file-to-identify-changes)
<!-- tocstop -->

# Usage

This plugin is used to take snapshot of commands and flags in OCLIF plugins. These snapshots can be used to enforce a deprecation policy or to keep track of changes.

To include it in your plugin, add it to the `devPlugins` section in your package.json.
Expand All @@ -32,12 +34,12 @@ Use the `snapshot:generate` command in your development process.

```sh-session
# generates a snapshot file that has a list or commands and flags in the current CLI or plugin
$ ./bin/run snapshot:generate
$ ./bin/run.js snapshot:generate
```

Use the `snapshot:compare` command in your continuos integration. This command will fail if changes are detected. The snapshot file should be updated and committed to the repository when legitimate changes are made.

```sh-session
# compare the current CLI or plugin commands and flags with a snapshot file to identify changes
$ ./bin/run snapshot:compare
$ ./bin/run.js snapshot:compare
```
18 changes: 0 additions & 18 deletions bin/dev

This file was deleted.

2 changes: 1 addition & 1 deletion bin/dev.cmd
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
@echo off

node "%~dp0\dev" %*
node --loader ts-node/esm --no-warnings=ExperimentalWarning "%~dp0\dev" %*
8 changes: 8 additions & 0 deletions bin/dev.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env -S node --loader ts-node/esm --no-warnings=ExperimentalWarning
// eslint-disable-next-line node/shebang
async function main() {
const {execute} = await import('@oclif/core')
await execute({development: true, dir: import.meta.url})
}

await main()
5 changes: 0 additions & 5 deletions bin/run

This file was deleted.

9 changes: 9 additions & 0 deletions bin/run.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env node

// eslint-disable-next-line node/shebang
async function main() {
const {execute} = await import('@oclif/core')
await execute({dir: import.meta.url})
}

await main()
71 changes: 43 additions & 28 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,48 +1,58 @@
{
"name": "@oclif/plugin-command-snapshot",
"description": "generates and compares OCLIF plugins snapshot files",
"version": "4.0.15",
"version": "4.0.16-dev.1",
"author": "Salesforce",
"bugs": "https://github.com/oclif/plugin-command-snapshot/issues",
"dependencies": {
"@oclif/core": "^2.11.8",
"chalk": "^4.1.2",
"@oclif/core": "^3.5.0",
"@types/lodash.difference": "^4.5.8",
"chalk": "^5.3.0",
"just-diff": "^5.2.0",
"lodash": "^4.17.21",
"lodash.difference": "^4.5.0",
"lodash.get": "^4.4.2",
"lodash.sortby": "^4.7.0",
"semver": "^7.5.4",
"ts-json-schema-generator": "^1.4.0",
"tslib": "^2.6.2"
"ts-json-schema-generator": "^1.4.0"
},
"devDependencies": {
"@commitlint/config-conventional": "^12.1.4",
"@commitlint/config-conventional": "^18.0.0",
"@oclif/plugin-help": "^5.2.20",
"@oclif/test": "^2.5.6",
"@oclif/prettier-config": "^0.2.1",
"@oclif/test": "^3.0.2",
"@types/chai": "^4.3.9",
"@types/mocha": "^8",
"@types/node": "^15",
"@types/lodash.get": "^4.4.8",
"@types/lodash.sortby": "^4.7.8",
"@types/mocha": "^10.0.3",
"@types/node": "^18",
"@types/semver": "^7.5.4",
"chai": "^4",
"commitlint": "^12.1.4",
"eslint": "^7.32.0",
"eslint-config-oclif": "^4",
"eslint-config-oclif-typescript": "^1.0.3",
"husky": "6",
"mocha": "^8",
"commitlint": "^18.0.0",
"eslint": "^8.52.0",
"eslint-config-oclif": "^5.0.0",
"eslint-config-oclif-typescript": "^3.0.8",
"eslint-config-prettier": "^9.0.0",
"husky": "^8.0.3",
"lint-staged": "^15.0.2",
"mocha": "^10.2.0",
"nyc": "^15",
"oclif": "^3.17.2",
"sinon": "^11.1.2",
"ts-node": "^10",
"typescript": "^4.9.5"
"oclif": "^4.0.3",
"prettier": "^3.0.3",
"sinon": "^17.0.0",
"ts-node": "^10.9.1",
"typescript": "^5.2.2"
},
"engines": {
"node": ">=16.0.0"
"node": ">=18.0.0"
},
"exports": "./lib/index.js",
"files": [
"/lib",
"/npm-shrinkwrap.json",
"/oclif.manifest.json",
"/schemas",
"/yarn.lock"
"/yarn.lock",
"/oclif.lock"
],
"homepage": "https://github.com/oclif/plugin-command-snapshot",
"keywords": [
Expand All @@ -62,16 +72,21 @@
},
"devPlugins": [
"@oclif/plugin-help"
]
],
"flexibleTaxonomy": true,
"topicSeparator": " "
},
"repository": "oclif/plugin-command-snapshot",
"scripts": {
"build": "rm -rf lib && tsc -b",
"commitlint": "commitlint",
"postpack": "rm -f oclif.manifest.json",
"posttest": "eslint . --ext .ts --config .eslintrc",
"prepack": "rm -rf lib && tsc -b && oclif manifest . && oclif readme",
"lint": "eslint . --ext .ts",
"postpack": "rm -f oclif.lock oclif.manifest.json",
"posttest": "yarn lint",
"prepack": "rm -rf lib && tsc -b && oclif lock && oclif manifest . && oclif readme",
"prepare": "husky install",
"test": "nyc --extension .ts mocha --forbid-only \"test/**/*.test.ts\" --timeout 20000",
"version": "oclif readme && git add README.md"
}
}
},
"type": "module"
}
19 changes: 4 additions & 15 deletions schemas/schema-compare.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,18 @@
"path": {
"type": "array",
"items": {
"type": [
"string",
"number"
]
"type": ["number", "string"]
}
},
"value": {}
},
"required": [
"op",
"path",
"value"
],
"required": ["op", "path", "value"],
"additionalProperties": false
}
},
"Operation": {
"type": "string",
"enum": [
"add",
"replace",
"remove"
]
"enum": ["add", "replace", "remove"]
}
}
}
}
Loading

0 comments on commit b4cf7da

Please sign in to comment.