Skip to content

Commit

Permalink
Switch to pnpm, fix tests, update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
grant0417 committed Nov 21, 2023
1 parent 52e96b6 commit d17e71a
Show file tree
Hide file tree
Showing 59 changed files with 8,904 additions and 13,142 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js v16
uses: actions/setup-node@v3
- uses: actions/checkout@v4
- name: Use Node.js v20
uses: actions/setup-node@v4
with:
node-version: 16
node-version: 20
- uses: pnpm/action-setup@v2
- name: Install dependencies and build # build is a postinstall script
run: yarn --immutable
run: pnpm --frozen-lockfile
- name: Lint packages
run: yarn lint
run: pnpm lint
11 changes: 6 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x, 16.x, 18.x, 19.x]
node-version: [18.x, 20.x, 21.x]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- uses: pnpm/action-setup@v2
- name: Install dependencies and build # build is a postinstall script
run: yarn --immutable
run: pnpm --frozen-lockfile
- name: Test packages
run: yarn test
run: pnpm test
9 changes: 5 additions & 4 deletions .github/workflows/update-autocomplete-tools-spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ jobs:
push-to-fig-autocomplete:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v2
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- uses: pnpm/action-setup@v2
- run: |
yarn
yarn workspace @withfig/autocomplete-tools generate-spec > generated.ts
pnpm install
pnpm run --filter ./cli/tools-cli generate-spec > generated.ts
- name: 'Create Autocomplete PR'
uses: withfig/push-to-fig-autocomplete-action@v1
with:
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/update-create-completion-spec-spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ jobs:
push-to-fig-autocomplete:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v2
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- uses: pnpm/action-setup@v2
- run: |
yarn
yarn workspace create-completion-spec generate-spec > generated.ts
pnpm install
pnpm run --filter ./cli/create-completion-spec generate-spec > generated.ts
- name: 'Create Autocomplete PR'
uses: withfig/push-to-fig-autocomplete-action@v1
with:
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/update-publish-spec-to-team-spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ jobs:
push-to-fig-autocomplete:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v2
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- uses: pnpm/action-setup@v2
- run: |
yarn
yarn workspace @fig/publish-spec generate-spec > generated.ts
pnpm install
pnpm run --filter ./cli/publish-spec generate-spec > generated.ts
- name: 'Create Autocomplete PR'
uses: withfig/push-to-fig-autocomplete-action@v1
with:
Expand Down
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ dist-ssr
.eslintcache
.fig/
build/
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
*.log
.python-version
__pycache__/
Expand Down
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

yarn pre-commit
pnpm pre-commit
1 change: 1 addition & 0 deletions .node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20
1 change: 1 addition & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/** @type {import("prettier").Config} */
module.exports = {
printWidth: 100,
singleQuote: false,
Expand Down
546 changes: 0 additions & 546 deletions .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs

This file was deleted.

28 changes: 0 additions & 28 deletions .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs

This file was deleted.

873 changes: 0 additions & 873 deletions .yarn/releases/yarn-3.5.0.cjs

This file was deleted.

9 changes: 0 additions & 9 deletions .yarnrc.yml

This file was deleted.

6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ Hey there! We are glad you want to contribute to some autocomplete package, here

1. Open an issue to get some feedback from the Fig team on your problem so that you don't risk to waste hours of work
2. Once you got some feedback you can fork the repo and clone in on your machine
3. Run `yarn` in the root of the monorepo to get the deps installed
3. Run `pnpm install` in the root of the monorepo to get the deps installed
4. Work on the new feature/fix, be sure to follow conventions
5. Add tests for the edits done , (run all the tests from the root of the repo using `yarn test` or from each specific package using `yarn workspace <package name> test`)
5. Add tests for the edits done , (run all the tests from the root of the repo using `pnpm test` or from each specific package using `pnpm run --filter ./<package name> test`)
6. Push to your fork
7. Open a PR
8. Enjoy the feat/fix live!

## Structure of the repo

We are using yarn workspaces in this repo. All CLIs are under the cli/ folder, while most of the other packages are in the root of the repo.
We are using pnpm workspaces in this repo. All CLIs are under the cli/ folder, while most of the other packages are in the root of the repo.
Concerning `npm` commands there are some global ones available from the root of the monorepo and some other relative to the packages.

## What is a good PR?
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ This repo contains the source for all of Fig tools related with [autocomplete](h
- The git tag should be: `<package_name>@<new_numerical_version>`
- Example: `git tag @fig/[email protected]`

4) Run `yarn workspace <workspace name> npm publish`
4) Run `pnpm publish ./<package>`

> **IMPORTANT**: remember to tag the new package version following the current conventions (see the previous tags of a package)
> this is important for some workflows we are running and to keep track of when releases were done.
Expand All @@ -47,7 +47,7 @@ This repo contains the source for all of Fig tools related with [autocomplete](h
e.g.
```bash
yarn workspace @withfig/autocomplete-types npm publish
pnpm publish ./types
```

> Note: `<workspace name>` is not the name of the folder, but the name specified inside the package.json of the package to publish.
Expand Down
2 changes: 1 addition & 1 deletion cli/create-completion-spec/boilerplate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@
"lint-staged": "^12.4.1",
"prettier": "^2.6.2",
"pretty-quick": "^3.1.3",
"typescript": "^4.6.4"
"typescript": "~5.2.0"
}
}
10 changes: 5 additions & 5 deletions cli/create-completion-spec/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"main": "lib/index.js",
"scripts": {
"build": "tsc",
"prepack": "yarn build",
"generate-spec": "ts-node generate-spec.ts generate-fig-spec"
"prepack": "pnpm build",
"generate-spec": "tsx generate-spec.ts generate-fig-spec"
},
"repository": {
"type": "git",
Expand All @@ -29,13 +29,13 @@
},
"homepage": "https://github.com/withfig/autocomplete-tools#readme",
"dependencies": {
"commander": "^9.2.0",
"commander": "^9.5.0",
"picocolors": "^1.0.0"
},
"devDependencies": {
"@fig/complete-commander": "workspace:^",
"ts-node": "^10.7.0",
"typescript": "^4.6.4"
"tsx": "^4.1.4",
"typescript": "~5.2.0"
},
"publishConfig": {
"access": "public"
Expand Down
36 changes: 18 additions & 18 deletions cli/publish-spec/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
"main": "./lib/index.js",
"type": "module",
"scripts": {
"run-script": "yarn build && node ./lib/bin.js",
"run-script": "pnpm build && node ./lib/bin.js",
"build": "tsc",
"prepack": "yarn build",
"test:server": "TEST_PORT=3005 ts-node test/server.ts",
"test:fixtures": "BASE_URL=http://localhost:3005 ts-node test/index.ts",
"prepack": "pnpm build",
"test:server": "TEST_PORT=3005 node --import tsx test/server.ts",
"test:fixtures": "BASE_URL=http://localhost:3005 tsx test/index.ts",
"test": "./test.sh",
"test:overwrite": "OVERWRITE=true yarn test",
"generate-spec": "ts-node generate-spec.ts generate-fig-spec"
"test:overwrite": "OVERWRITE=true pnpm test",
"generate-spec": "node --import tsx generate-spec.ts generate-fig-spec"
},
"fig": {
"test:server": "Start a mock server emulating the production one",
Expand Down Expand Up @@ -46,24 +46,24 @@
},
"homepage": "https://github.com/withfig/autocomplete-tools#readme",
"dependencies": {
"commander": "^9.2.0",
"esbuild": "^0.14.38",
"node-fetch": "^3.2.4",
"prettier": "^2.3.2",
"commander": "^9.5.0",
"esbuild": "^0.19.6",
"node-fetch": "^3.3.2",
"prettier": "^3.1.0",
"prompts": "^2.4.2"
},
"devDependencies": {
"@fig/complete-commander": "workspace:^",
"@types/express": "^4.17.13",
"@types/multer": "^1.4.7",
"@types/node": "^14.18.21",
"@types/node-fetch": "^2.6.1",
"@types/express": "^4.17.21",
"@types/multer": "^1.4.10",
"@types/node": "^20.9.2",
"@types/node-fetch": "^2.6.9",
"@types/prompts": "latest",
"express": "^4.18.1",
"multer": "^1.4.4",
"express": "^4.18.2",
"multer": "1.4.5-lts.1",
"picocolors": "^1.0.0",
"ts-node": "^10.7.0",
"typescript": "^4.4.2"
"tsx": "^4.1.4",
"typescript": "~5.2.0"
},
"publishConfig": {
"access": "public"
Expand Down
2 changes: 2 additions & 0 deletions cli/publish-spec/src/validation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ interface Chainable<T = Record<string, never>> {
* > NOTE: Order of validators in the chain matters!
*/
export function validate(options: RunOptions): Chainable {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const validators: Validator<any>[] = [];

// eslint-disable-next-line @typescript-eslint/no-explicit-any
async function exec(): Promise<any> {
const interactiveQuestions: prompts.PromptObject<string>[] = [];
const validatedOptions = {};
Expand Down
8 changes: 5 additions & 3 deletions cli/publish-spec/test.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#!/usr/bin/env bash

# We had to extract this script to a file because yarn crashes when it finds a `!` in an npm script
# We are using npm here because the pid returned by yarn is wrong and would not shut down the server
npm run test:server &
set -e

# We had to extract this script to a file because pnpm crashes when it finds a `!` in an npm script
# We are using npm here because the pid returned by pnpm is wrong and would not shut down the server
TEST_PORT=3005 node --import tsx test/server.ts &
SERVER_PID=$! &&
sleep 2 && # Arbitrary time
npm run test:fixtures
Expand Down
5 changes: 5 additions & 0 deletions cli/publish-spec/test/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,8 @@ process.on("SIGTERM", () => {
console.log(pc.yellow(`Stopped listening on ${PORT}`));
server.close();
});

process.on("SIGINT", () => {
console.log(pc.yellow(`Stopped listening on ${PORT}`));
server.close();
});
33 changes: 16 additions & 17 deletions cli/tools-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,38 @@
"author": "The Fig Team",
"scripts": {
"build": "rm -rf build/ && tsc",
"test": "ts-node test/index.ts",
"test:overwrite": "OVERWRITE=true yarn test",
"prepack": "yarn build",
"generate-spec": "ts-node generate-spec.ts generate-fig-spec"
"test": "tsx test/index.ts",
"test:overwrite": "OVERWRITE=true pnpm test",
"prepack": "pnpm build",
"generate-spec": "tsx generate-spec.ts generate-fig-spec"
},
"license": "MIT",
"bin": "./build/bin.js",
"dependencies": {
"@esbuild-plugins/node-modules-polyfill": "^0.2.2",
"@fig/autocomplete-helpers": "workspace:^",
"@fig/autocomplete-merge": "workspace:^",
"@types/semver": "^7.3.9",
"chalk": "^4.1.0",
"chokidar": "^3.5.1",
"commander": "^8.1.0",
"@types/semver": "^7.5.5",
"chalk": "^4.1.2",
"chokidar": "^3.5.3",
"commander": "^8.3.0",
"create-completion-spec": "workspace:^",
"esbuild": "^0.14.39",
"fast-glob": "^3.2.7",
"module-from-string": "^3.1.4",
"prettier": "^2.4.1",
"semver": "^7.5.2",
"typescript": "^4.6.4"
"esbuild": "^0.19.6",
"fast-glob": "^3.3.2",
"module-from-string": "^3.3.0",
"prettier": "^3.1.0",
"semver": "^7.5.4",
"typescript": "~5.2.0"
},
"types": "build/index.d.ts",
"files": [
"build/"
],
"devDependencies": {
"@fig/complete-commander": "workspace:^",
"@types/node": "^14.14.33",
"@types/prettier": "^2.4.1",
"@types/node": "^20.9.2",
"@withfig/autocomplete-types": "workspace:^",
"ts-node": "^10.7.0"
"tsx": "^4.1.4"
},
"fig": {
"build": {
Expand Down
16 changes: 2 additions & 14 deletions cli/tools-cli/src/scripts/compile.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,17 @@
import { build } from "esbuild";
import { NodeModulesPolyfillPlugin } from "@esbuild-plugins/node-modules-polyfill";
import { exec } from "child_process";
import chokidar from "chokidar";
import { Command } from "commander";
import glob from "fast-glob";
import SpecLogger, { Level } from "./log";
import { setSetting } from "./settings";

// Folder names
const SOURCE_FOLDER_NAME = "src";
const DESTINATION_FOLDER_NAME = "build";

function execWithError(command: string, logNodeErrors = false) {
exec(command, (error, stdout, stderr) => {
if (logNodeErrors && error) {
SpecLogger.log(`node error running "${command}": ${error.message}`, Level.ERROR);
return;
}
if (stderr) {
SpecLogger.log(`shell error running "${command}": ${stderr}`, Level.ERROR);
}
});
}

function invalidateCache() {
execWithError("fig settings autocomplete.developerModeNPMInvalidateCache true");
setSetting("autocomplete.developerModeNPMInvalidateCache", true);
}

/**
Expand Down
Loading

0 comments on commit d17e71a

Please sign in to comment.