Skip to content

Commit

Permalink
Merge pull request #94 from deinsoftware/dev
Browse files Browse the repository at this point in the history
test: 🧪 command and alias e2e test
  • Loading branch information
equiman authored Oct 19, 2023
2 parents 0c5950a + dc31565 commit 64a080c
Show file tree
Hide file tree
Showing 71 changed files with 707 additions and 221 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,4 @@ jobs:
-Dsonar.projectVersion=${{ steps.package.outputs.version }}
-Dsonar.javascript.lcov.reportPaths=coverage/lcov.info
-Dsonar.coverage.exclusions=**/*.test.ts
-Dsonar.cpd.exclusions=**/*.test.ts
2 changes: 2 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
node_modules/
types/
**/*.types.*
**/*.map.*
build/
swpm*.tgz
tsconfig.build.tsbuildinfo
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"CHEATSHEET",
"cmdr",
"cmds",
"Codeium",
"dein",
"deinsoftware",
"Dsonar",
Expand Down
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,21 @@ Fixed for any bug fixes.
Security to invite users to upgrade in case of vulnerabilities.
-->

## 2.5.0 - 2023/10/19

### Changed

- typescript strict configuration
- bump package versions

### Fixed

- `--global` flag position on `yarn` and `yarn@berry` with `interactive` command

### Added

- e2e testing for complete set of commands and aliases

## 2.4.0 - 2023/10/16

### Added
Expand Down
4 changes: 2 additions & 2 deletions CHEATSHEET.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ This is a cheat sheet that you can use as a handy reference for [npm](https://ww
| [x] | remove package as `optionalDependencies` | `swpm remove <package> --save-optional` | `npm uninstall <package> --save-optional` | `yarn remove <package> --optional` | `yarn remove <package> --optional` | `pnpm uninstall <package> --save-optional` | `bun remove <package> --optional` |
| [x] | remove package as `peerDependencies` | `swpm remove <package> --save-peer` | `npm uninstall <package> --save-peer` | `yarn remove <package> --peer` | `yarn remove <package> --peer` | `pnpm uninstall <package> --save-peer` | N/A |
| [x] | update package (no `package.json`) | `swpm update [<package>] [--global]` | `npm update [<package>] [--location=global]` | `yarn [global] upgrade [<package>]` | `yarn [global] semver up [<package>]` | `pnpm update [<package>] [--global]` | N/A |
| [x] | upgrade package on `package.json` | `swpm upgrade <package> [--global]` | `npm install <package>@latest [--location=global]` | `yarn [global] upgrade <package> --latest` | `yarn [global] up <package>` | `pnpm update <package> --latest [--global]` | N/A |
| [x] | upgrade interactive | `swpm interactive` | N/A | `yarn upgrade-interactive` | `yarn upgrade-interactive` | `pnpm update --interactive` | N/A |
| [x] | upgrade package on `package.json` | `swpm upgrade <package> [--global]` | `npm add <package>@latest [--location=global]` | `yarn [global] upgrade <package> --latest` | `yarn [global] up <package>` | `pnpm update <package> --latest [--global]` | N/A |
| [x] | upgrade interactive | `swpm interactive` | N/A | `yarn upgrade-interactive` | `yarn upgrade-interactive` | `pnpm upgrade --interactive` | N/A |
| [ ] | list all package at the top level | | `npm list --depth 0 [--location=global]` | `yarn [global] list --depth 0` | `yarn [global] list --depth 0` | `pnpm list --depth 0 [--global]` | `bun pm ls` |
| [ ] | audit vulnerable dependencies | | `npm audit [fix]` | `yarn audit` | `yarn audit` | `pnpm audit [--fix]` | |

Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ Quick and short aliases for `swpm` and `swpx` commands.

| Package/Alias | `sug <package>` | `sug vite` |
| -------------- | --------------------------------- | ---------------------------- |
| **npm** | `npm install <package>@latest` | `npm install <vite>@latest` |
| **npm** | `npm add <package>@latest` | `npm add vite@latest` |
| **yarn** | `yarn upgrade <package> --latest` | `yarn upgrade vite --latest` |
| **yarn@berry** | `yarn up <package>` | `yarn up vite` |
| **pnpm** | `pnpm update <package> --latest` | `pnpm update vite --latest` |
Expand Down Expand Up @@ -579,7 +579,7 @@ Quick and short aliases for `swpm` and `swpx` commands.
| **npm** | `npm run <script>` | `npm run dev -- --port 3030` |
| **yarn** | `yarn run <script>` | `yarn run dev --port 3030` |
| **pnpm** | `pnpm run <script>` | `pnpm run dev --port 3030` |
| **bun** | `bun run <script>` | `bun add dev --port 3030` |
| **bun** | `bun run <script>` | `bun run dev --port 3030` |

### sx (execute)

Expand Down Expand Up @@ -820,6 +820,7 @@ A minimalistic solution focus only in the most common used commands:
- [Node.js](https://nodejs.org/) - A JavaScript runtime built on Chrome's V8 JavaScript engine.
- [ESLint](https://eslint.org/) - Find and fix problems in your JavaScript code.
- [vitest](https://vitest.dev/) - A blazing fast unit-test framework powered by Vite ⚡️.
- [Codeium](https://codeium.com/) - Free AI code completion and chat.

### NPM Packages

Expand Down
80 changes: 34 additions & 46 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 9 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "swpm",
"version": "2.4.0",
"version": "2.5.0",
"engines": {
"node": ">=16"
},
Expand Down Expand Up @@ -95,7 +95,6 @@
"type": "module",
"dependencies": {
"chalk": "5.3.0",
"ci": "^2.3.0",
"command-exists": "1.2.9",
"common-tags": "1.8.2",
"find-up": "6.3.0",
Expand All @@ -107,13 +106,13 @@
"yargs": "17.7.2"
},
"devDependencies": {
"@types/command-exists": "1.2.1",
"@types/common-tags": "1.8.2",
"@types/prompts": "2.4.6",
"@types/semver": "7.5.3",
"@types/spinnies": "0.5.1",
"@types/update-notifier": "6.0.5",
"@types/yargs": "17.0.28",
"@types/command-exists": "1.2.2",
"@types/common-tags": "1.8.3",
"@types/prompts": "2.4.7",
"@types/semver": "7.5.4",
"@types/spinnies": "0.5.2",
"@types/update-notifier": "6.0.6",
"@types/yargs": "17.0.29",
"@typescript-eslint/eslint-plugin": "6.8.0",
"@typescript-eslint/parser": "6.8.0",
"@vitest/coverage-v8": "0.34.6",
Expand All @@ -122,7 +121,7 @@
"eslint-plugin-import": "2.28.1",
"eslint-plugin-n": "16.2.0",
"eslint-plugin-promise": "6.1.1",
"type-fest": "4.4.0",
"type-fest": "4.5.0",
"typescript": "5.2.2",
"vitest": "0.34.6"
},
Expand Down
10 changes: 10 additions & 0 deletions src/alias/sa.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { it, expect, describe } from 'vitest'
import { testCommandResult } from '../../.vitest/helpers'
import { addCases } from '../cli/swpm/commands/add.test'

describe('sa', () => {
it.each(addCases)('%s', (pkg, expected) => {
const result = testCommandResult(`sa vite --test ${pkg}`)
expect(result).toBe(expected)
})
})
10 changes: 10 additions & 0 deletions src/alias/sad.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { it, expect, describe } from 'vitest'
import { testCommandResult } from '../../.vitest/helpers'
import { addDevCases } from '../cli/swpm/commands/add.test'

describe('sad', () => {
it.each(addDevCases)('%s', (pkg, expected) => {
const result = testCommandResult(`sad vite --test ${pkg}`)
expect(result).toBe(expected)
})
})
15 changes: 15 additions & 0 deletions src/alias/sade.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { it, expect, describe } from 'vitest'
import { testCommandResult } from '../../.vitest/helpers'

describe('sade', () => {
it.each([
['npm', 'npm add vite --save-dev --save-exact'],
['yarn', 'yarn add vite --dev --exact'],
['yarn@berry', 'yarn add vite --dev --exact'],
['pnpm', 'pnpm add vite --save-dev --save-exact'],
['bun', 'bun add vite --dev --exact']
])('%s', (pkg, expected) => {
const result = testCommandResult(`sade vite --test ${pkg}`)
expect(result).toBe(expected)
})
})
10 changes: 10 additions & 0 deletions src/alias/sae.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { it, expect, describe } from 'vitest'
import { testCommandResult } from '../../.vitest/helpers'
import { addSaveExact } from '../cli/swpm/commands/add.test'

describe('sae', () => {
it.each(addSaveExact)('%s', (pkg, expected) => {
const result = testCommandResult(`sae vite --test ${pkg}`)
expect(result).toBe(expected)
})
})
12 changes: 12 additions & 0 deletions src/alias/sag.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { it, expect, describe } from 'vitest'
import { testCommandResult } from '../../.vitest/helpers'
import { addPackageCases, addVoltaCases } from '../cli/swpm/commands/add.test'

const voltaVersion = testCommandResult('volta --version')

describe('sag', () => {
it.each(voltaVersion ? addVoltaCases : addPackageCases)('%s', (pkg, expected) => {
const result = testCommandResult(`sag vite --test ${pkg}`)
expect(result).toBe(expected)
})
})
24 changes: 24 additions & 0 deletions src/alias/si.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { it, expect, describe } from 'vitest'
import { testCommandResult } from '../../.vitest/helpers'
import { installCases, installFrozenCases, installLockCases } from '../cli/swpm/commands/install.test'

describe('si', () => {
it.each(installCases)('%s', (pkg, expected) => {
const result = testCommandResult(`si --test ${pkg}`)
expect(result).toBe(expected)
})
})

describe('si --frozen', () => {
it.each(installFrozenCases)('%s', (pkg, expected) => {
const result = testCommandResult(`si --frozen --test ${pkg}`)
expect(result).toBe(expected)
})
})

describe('si --package-lock', () => {
it.each(installLockCases)('%s', (pkg, expected) => {
const result = testCommandResult(`si --package-lock --test ${pkg}`)
expect(result).toBe(expected)
})
})
10 changes: 10 additions & 0 deletions src/alias/sif.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { it, expect, describe } from 'vitest'
import { testCommandResult } from '../../.vitest/helpers'
import { installFrozenCases } from '../cli/swpm/commands/install.test'

describe('sif', () => {
it.each(installFrozenCases)('%s', (pkg, expected) => {
const result = testCommandResult(`sif --test ${pkg}`)
expect(result).toBe(expected)
})
})
15 changes: 15 additions & 0 deletions src/alias/sr.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { it, expect, describe } from 'vitest'
import { testCommandResult } from '../../.vitest/helpers'

describe('sr', () => {
it.each([
['npm', 'npm run dev -- --port 3030'],
['yarn', 'yarn run dev --port 3030'],
['yarn@berry', 'yarn run dev --port 3030'],
['pnpm', 'pnpm run dev --port 3030'],
['bun', 'bun run dev --port 3030']
])('%s', (pkg, expected) => {
const result = testCommandResult(`sr dev --port 3030 --test ${pkg}`)
expect(result).toBe(expected)
})
})
Loading

0 comments on commit 64a080c

Please sign in to comment.