Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/mighty-frogs-fail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@manypkg/cli": minor
"@manypkg/find-root": major
"@manypkg/get-packages": major
"@manypkg/tools": major
---

This package is now published as a [pure ESM package](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c).
13 changes: 13 additions & 0 deletions .github/actions/ci-setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Setup CI

runs:
using: composite
steps:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: ".node-version"

- name: Install dependencies
shell: bash
run: yarn install --frozen-lockfile
14 changes: 2 additions & 12 deletions .github/workflows/changeset-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,11 @@ jobs:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: ./.github/actions/ci-setup

- name: Set Node.js 18.x
uses: actions/setup-node@v3
with:
node-version: 18.x

- name: Install Yarn
run: npm install --global yarn

- name: Install Dependencies
run: yarn
- run: git branch -a

- name: "Create Pull Request or Publish to npm"
Expand Down
44 changes: 8 additions & 36 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,8 @@ jobs:
name: Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set Node.js 18.x
uses: actions/setup-node@v3
with:
node-version: 18.x

- name: Install Dependencies
run: yarn
- uses: actions/checkout@v4
- uses: ./.github/actions/ci-setup

- name: Run Tests
run: yarn test
Expand All @@ -28,15 +21,8 @@ jobs:
name: TypeScript
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set Node.js 18.x
uses: actions/setup-node@v3
with:
node-version: 18.x

- name: Install Dependencies
run: yarn
- uses: actions/checkout@v4
- uses: ./.github/actions/ci-setup

- name: Check Types
run: yarn tsc
Expand All @@ -45,15 +31,8 @@ jobs:
name: Formatting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set Node.js 18.x
uses: actions/setup-node@v3
with:
node-version: 18.x

- name: Install Dependencies
run: yarn
- uses: actions/checkout@v4
- uses: ./.github/actions/ci-setup

- name: Check Formatting
run: yarn format:check
Expand All @@ -62,15 +41,8 @@ jobs:
name: Knip
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set Node.js 18.x
uses: actions/setup-node@v3
with:
node-version: 18.x

- name: Install Dependencies
run: yarn
- uses: actions/checkout@v4
- uses: ./.github/actions/ci-setup

- name: Check Knip
run: yarn knip
1 change: 1 addition & 0 deletions .node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v22.14.0
2 changes: 1 addition & 1 deletion knip.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"ignoreWorkspaces": ["test-gatsby", "packages/gatsby-source-workspace"],
"workspaces": {
".": {
"ignoreBinaries": ["gatsby", "manypkg"]
"ignoreBinaries": ["gatsby", "packages/cli/bin.js"]
}
},
"ignore": ["__fixtures__/**"]
Expand Down
11 changes: 8 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"scripts": {
"format": "prettier --write .",
"format:check": "prettier --check .",
"postinstall": "preconstruct dev && manypkg check",
"postinstall": "preconstruct dev && NODE_OPTIONS=--experimental-strip-types packages/cli/bin.js check",
"knip": "knip",
"release": "preconstruct build && changeset publish",
"test": "jest",
Expand All @@ -29,7 +29,7 @@
"@babel/preset-typescript": "^7.18.6",
"@changesets/changelog-github": "^0.4.8",
"@changesets/cli": "^2.26.0",
"@preconstruct/cli": "^2.8.9",
"@preconstruct/cli": "^2.8.12",
"@types/jest": "^29.2.4",
"@types/normalize-path": "^3.0.0",
"@types/parse-github-url": "^1.0.0",
Expand All @@ -46,8 +46,13 @@
"packages": [
"packages/!(gatsby)*"
],
"exports": {
"importConditionDefaultExport": "default"
},
"___experimentalFlags_WILL_CHANGE_IN_PATCH": {
"keepDynamicImportAsDynamicImportInCommonJS": true
"distInRoot": true,
"importsConditions": true,
"typeModule": true
}
}
}
4 changes: 1 addition & 3 deletions packages/cli/bin.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
#!/usr/bin/env node
"use strict";

require(".");
import "@manypkg/cli";
9 changes: 6 additions & 3 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,19 @@
"directory": "packages/cli"
},
"license": "MIT",
"main": "dist/manypkg-cli.cjs.js",
"module": "dist/manypkg-cli.esm.js",
"type": "module",
"exports": {
".": "./dist/manypkg-cli.js",
"./package.json": "./package.json"
},
"bin": {
"manypkg": "./bin.js"
},
"dependencies": {
"@manypkg/get-packages": "^2.2.1",
"detect-indent": "^6.0.0",
"normalize-path": "^3.0.0",
"p-limit": "^2.2.1",
"p-limit": "^6.2.0",
"package-json": "^10.0.1",
"parse-github-url": "^1.0.2",
"picocolors": "^1.1.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/checks/EXTERNAL_MISMATCH.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import {
makeCheck,
getMostCommonRangeMap,
NORMAL_DEPENDENCY_TYPES,
} from "./utils";
import { Package } from "@manypkg/get-packages";
} from "./utils.ts";
import type { Package } from "@manypkg/get-packages";
import { validRange } from "semver";

type ErrorType = {
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/checks/INCORRECT_REPOSITORY_FIELD.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import parseGithubUrl from "parse-github-url";
import normalizePath from "normalize-path";
import { Package } from "@manypkg/get-packages";
import type { Package } from "@manypkg/get-packages";

import { makeCheck } from "./utils";
import { makeCheck } from "./utils.ts";

type ErrorType = {
type: "INCORRECT_REPOSITORY_FIELD";
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/checks/INTERNAL_MISMATCH.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import {
makeCheck,
NORMAL_DEPENDENCY_TYPES,
versionRangeToRangeType,
} from "./utils";
} from "./utils.ts";
import semver from "semver";
import { Package } from "@manypkg/get-packages";
import type { Package } from "@manypkg/get-packages";

export type ErrorType = {
type: "INTERNAL_MISMATCH";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { makeCheck, getMostCommonRangeMap } from "./utils";
import { Package } from "@manypkg/get-packages";
import { makeCheck, getMostCommonRangeMap } from "./utils.ts";
import type { Package } from "@manypkg/get-packages";
import { upperBoundOfRangeAWithinBoundsOfB } from "sembear";
import semver from "semver";

Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/checks/INVALID_PACKAGE_NAME.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Package } from "@manypkg/get-packages";
import type { Package } from "@manypkg/get-packages";
import { makeCheck } from "./utils.ts";
import validateNpmPackageName from "validate-npm-package-name";
import { makeCheck } from "./utils";

type ErrorType = {
type: "INVALID_PACKAGE_NAME";
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/checks/MULTIPLE_DEPENDENCY_TYPES.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { makeCheck } from "./utils";
import { Package } from "@manypkg/get-packages";
import { makeCheck } from "./utils.ts";
import type { Package } from "@manypkg/get-packages";

type ErrorType = {
type: "MULTIPLE_DEPENDENCY_TYPES";
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/checks/ROOT_HAS_PROD_DEPENDENCIES.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { makeCheck, sortObject } from "./utils";
import { makeCheck, sortObject } from "./utils.ts";
import pc from "picocolors";
import { Package } from "@manypkg/get-packages";
import type { Package } from "@manypkg/get-packages";

type ErrorType = {
type: "ROOT_HAS_PROD_DEPENDENCIES";
Expand Down
9 changes: 7 additions & 2 deletions packages/cli/src/checks/UNSORTED_DEPENDENCIES.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { makeCheck, DEPENDENCY_TYPES, sortDeps, isArrayEqual } from "./utils";
import { Package } from "@manypkg/get-packages";
import {
makeCheck,
DEPENDENCY_TYPES,
sortDeps,
isArrayEqual,
} from "./utils.ts";
import type { Package } from "@manypkg/get-packages";

type ErrorType = {
type: "UNSORTED_DEPENDENCIES";
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/checks/WORKSPACE_REQUIRED.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { makeCheck, NORMAL_DEPENDENCY_TYPES } from "./utils";
import { Package } from "@manypkg/get-packages";
import { makeCheck, NORMAL_DEPENDENCY_TYPES } from "./utils.ts";
import type { Package } from "@manypkg/get-packages";

type ErrorType = {
type: "WORKSPACE_REQUIRED";
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/checks/__tests__/EXTERNAL_MISMATCH.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import internalMismatch from "../EXTERNAL_MISMATCH";
import { getWS, getFakeWS, getRootWS } from "../../test-helpers";
import internalMismatch from "../EXTERNAL_MISMATCH.ts";
import { getWS, getFakeWS, getRootWS } from "../../test-helpers.ts";

let rootWorkspace = getRootWS();

Expand Down
10 changes: 7 additions & 3 deletions packages/cli/src/checks/__tests__/INCORRECT_REPOSITORY_FIELD.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import path from "path";
import check from "../INCORRECT_REPOSITORY_FIELD";
import { getWS, getFakeWS, getFakeString, getRootWS } from "../../test-helpers";
import {
getFakeString,
getFakeWS,
getRootWS,
getWS,
} from "../../test-helpers.ts";
import check from "../INCORRECT_REPOSITORY_FIELD.ts";

describe("incorrect repository field", () => {
describe("github", () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/checks/__tests__/INTERNAL_MISMATCH.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import makeCheck, { ErrorType } from "../INTERNAL_MISMATCH";
import { getWS, getFakeWS, getRootWS } from "../../test-helpers";
import { getFakeWS, getRootWS, getWS } from "../../test-helpers.ts";
import makeCheck, { ErrorType } from "../INTERNAL_MISMATCH.ts";

let rootWorkspace = getRootWS();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import makeCheck from "../INVALID_DEV_AND_PEER_DEPENDENCY_RELATIONSHIP";
import { getWS, getFakeWS, getRootWS } from "../../test-helpers";
import { getFakeWS, getRootWS, getWS } from "../../test-helpers.ts";
import makeCheck from "../INVALID_DEV_AND_PEER_DEPENDENCY_RELATIONSHIP.ts";

let rootWorkspace = getRootWS();

Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/checks/__tests__/WORKSPACE_REQUIRED.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getWS, getFakeWS, getRootWS } from "../../test-helpers";
import makeCheck from "../WORKSPACE_REQUIRED";
import { getFakeWS, getRootWS, getWS } from "../../test-helpers.ts";
import makeCheck from "../WORKSPACE_REQUIRED.ts";
let rootWorkspace = getRootWS();

test("should not error if not using workspaceProtocol: require", () => {
Expand Down
18 changes: 9 additions & 9 deletions packages/cli/src/checks/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import EXTERNAL_MISMATCH from "./EXTERNAL_MISMATCH";
import INTERNAL_MISMATCH from "./INTERNAL_MISMATCH";
import INVALID_DEV_AND_PEER_DEPENDENCY_RELATIONSHIP from "./INVALID_DEV_AND_PEER_DEPENDENCY_RELATIONSHIP";
import INVALID_PACKAGE_NAME from "./INVALID_PACKAGE_NAME";
import MULTIPLE_DEPENDENCY_TYPES from "./MULTIPLE_DEPENDENCY_TYPES";
import ROOT_HAS_PROD_DEPENDENCIES from "./ROOT_HAS_PROD_DEPENDENCIES";
import UNSORTED_DEPENDENCIES from "./UNSORTED_DEPENDENCIES";
import INCORRECT_REPOSITORY_FIELD from "./INCORRECT_REPOSITORY_FIELD";
import WORKSPACE_REQUIRED from "./WORKSPACE_REQUIRED";
import EXTERNAL_MISMATCH from "./EXTERNAL_MISMATCH.ts";
import INTERNAL_MISMATCH from "./INTERNAL_MISMATCH.ts";
import INVALID_DEV_AND_PEER_DEPENDENCY_RELATIONSHIP from "./INVALID_DEV_AND_PEER_DEPENDENCY_RELATIONSHIP.ts";
import INVALID_PACKAGE_NAME from "./INVALID_PACKAGE_NAME.ts";
import MULTIPLE_DEPENDENCY_TYPES from "./MULTIPLE_DEPENDENCY_TYPES.ts";
import ROOT_HAS_PROD_DEPENDENCIES from "./ROOT_HAS_PROD_DEPENDENCIES.ts";
import UNSORTED_DEPENDENCIES from "./UNSORTED_DEPENDENCIES.ts";
import INCORRECT_REPOSITORY_FIELD from "./INCORRECT_REPOSITORY_FIELD.ts";
import WORKSPACE_REQUIRED from "./WORKSPACE_REQUIRED.ts";

export let checks = {
EXTERNAL_MISMATCH,
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/checks/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Package } from "@manypkg/get-packages";
import type { Package } from "@manypkg/get-packages";
import * as semver from "semver";
import { highest } from "sembear";

Expand Down
24 changes: 14 additions & 10 deletions packages/cli/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import path from "path";
import * as logger from "./logger";
import { getPackages, Packages, Package } from "@manypkg/get-packages";
import { Options } from "./checks/utils";
import { checks } from "./checks";
import { ExitError } from "./errors";
import { writePackage, install } from "./utils";
import { runCmd } from "./run";
import { upgradeDependency } from "./upgrade";
import { npmTagAll } from "./npm-tag";
import path from "node:path";
import * as logger from "./logger.ts";
import {
getPackages,
type Packages,
type Package,
} from "@manypkg/get-packages";
import type { Options } from "./checks/utils.ts";
import { checks } from "./checks/index.ts";
import { ExitError } from "./errors.ts";
import { writePackage, install } from "./utils.ts";
import { runCmd } from "./run.ts";
import { upgradeDependency } from "./upgrade.ts";
import { npmTagAll } from "./npm-tag.ts";
import { exec } from "tinyexec";
import pLimit from "p-limit";

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/logger.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pc from "picocolors";
import util from "util";
import util from "node:util";

function format(
args: Array<any>,
Expand Down
Loading