diff --git a/.changeset/tiny-geckos-allow.md b/.changeset/tiny-geckos-allow.md new file mode 100644 index 0000000000..127e8d0b4b --- /dev/null +++ b/.changeset/tiny-geckos-allow.md @@ -0,0 +1,6 @@ +--- +"@pnpm/building.after-install": major +"@pnpm/building.policy": major +--- + +Initial release. diff --git a/building/after-install/README.md b/building/after-install/README.md new file mode 100644 index 0000000000..6d91e786f9 --- /dev/null +++ b/building/after-install/README.md @@ -0,0 +1,17 @@ +# @pnpm/building.after-install + +> Rebuild packages that are already installed by running their lifecycle scripts + + +[![npm version](https://img.shields.io/npm/v/@pnpm/building.after-install.svg)](https://www.npmjs.com/package/@pnpm/building.after-install) + + +## Installation + +```sh +pnpm add @pnpm/building.after-install +``` + +## License + +MIT diff --git a/building/after-install/package.json b/building/after-install/package.json new file mode 100644 index 0000000000..9111cadff2 --- /dev/null +++ b/building/after-install/package.json @@ -0,0 +1,77 @@ +{ + "name": "@pnpm/building.after-install", + "version": "1000.0.0-0", + "description": "Rebuild packages that are already installed by running their lifecycle scripts", + "keywords": [ + "pnpm", + "pnpm11", + "rebuild" + ], + "license": "MIT", + "funding": "https://opencollective.com/pnpm", + "repository": "https://github.com/pnpm/pnpm/tree/main/building/after-install", + "homepage": "https://github.com/pnpm/pnpm/tree/main/building/after-install#readme", + "bugs": { + "url": "https://github.com/pnpm/pnpm/issues" + }, + "type": "module", + "main": "lib/index.js", + "types": "lib/index.d.ts", + "exports": { + ".": "./lib/index.js" + }, + "files": [ + "lib", + "!*.map" + ], + "scripts": { + "lint": "eslint \"src/**/*.ts\"", + "prepublishOnly": "pnpm run compile", + "compile": "tsgo --build && pnpm run lint --fix", + "test": "pnpm run compile" + }, + "dependencies": { + "@pnpm/building.policy": "workspace:*", + "@pnpm/calc-dep-state": "workspace:*", + "@pnpm/config": "workspace:*", + "@pnpm/constants": "workspace:*", + "@pnpm/core-loggers": "workspace:*", + "@pnpm/dependency-path": "workspace:*", + "@pnpm/deps.graph-sequencer": "workspace:*", + "@pnpm/error": "workspace:*", + "@pnpm/exec.pkg-requires-build": "workspace:*", + "@pnpm/get-context": "workspace:*", + "@pnpm/lifecycle": "workspace:*", + "@pnpm/link-bins": "workspace:*", + "@pnpm/lockfile.types": "workspace:*", + "@pnpm/lockfile.utils": "workspace:*", + "@pnpm/lockfile.walker": "workspace:*", + "@pnpm/modules-yaml": "workspace:*", + "@pnpm/normalize-registries": "workspace:*", + "@pnpm/npm-package-arg": "catalog:", + "@pnpm/read-package-json": "workspace:*", + "@pnpm/store-connection-manager": "workspace:*", + "@pnpm/store-controller-types": "workspace:*", + "@pnpm/store.cafs": "workspace:*", + "@pnpm/store.index": "workspace:*", + "@pnpm/types": "workspace:*", + "load-json-file": "catalog:", + "p-limit": "catalog:", + "run-groups": "catalog:", + "semver": "catalog:" + }, + "peerDependencies": { + "@pnpm/logger": "catalog:", + "@pnpm/worker": "workspace:^" + }, + "devDependencies": { + "@pnpm/building.after-install": "workspace:*", + "@types/semver": "catalog:" + }, + "engines": { + "node": ">=22.13" + }, + "jest": { + "preset": "@pnpm/jest-config" + } +} diff --git a/exec/plugin-commands-rebuild/src/implementation/extendRebuildOptions.ts b/building/after-install/src/extendRebuildOptions.ts similarity index 98% rename from exec/plugin-commands-rebuild/src/implementation/extendRebuildOptions.ts rename to building/after-install/src/extendRebuildOptions.ts index a9565e1cc1..e017e636d1 100644 --- a/exec/plugin-commands-rebuild/src/implementation/extendRebuildOptions.ts +++ b/building/after-install/src/extendRebuildOptions.ts @@ -58,7 +58,7 @@ Pick & Pick => { const packageManager = opts.packageManager ?? - await loadJsonFile<{ name: string, version: string }>(path.join(import.meta.dirname, '../../package.json'))! + await loadJsonFile<{ name: string, version: string }>(path.join(import.meta.dirname, '../package.json'))! const dir = opts.dir ?? process.cwd() const lockfileDir = opts.lockfileDir ?? dir return { diff --git a/exec/plugin-commands-rebuild/src/implementation/index.ts b/building/after-install/src/index.ts similarity index 99% rename from exec/plugin-commands-rebuild/src/implementation/index.ts rename to building/after-install/src/index.ts index 8f03c669c8..a81f47f557 100644 --- a/exec/plugin-commands-rebuild/src/implementation/index.ts +++ b/building/after-install/src/index.ts @@ -34,7 +34,7 @@ import type { ProjectId, ProjectRootDir, } from '@pnpm/types' -import { createAllowBuildFunction } from '@pnpm/builder.policy' +import { createAllowBuildFunction } from '@pnpm/building.policy' import { pkgRequiresBuild } from '@pnpm/exec.pkg-requires-build' import * as dp from '@pnpm/dependency-path' import { StoreIndex } from '@pnpm/store.index' diff --git a/building/after-install/tsconfig.json b/building/after-install/tsconfig.json new file mode 100644 index 0000000000..ae77206c1a --- /dev/null +++ b/building/after-install/tsconfig.json @@ -0,0 +1,85 @@ +{ + "extends": "@pnpm/tsconfig", + "compilerOptions": { + "outDir": "lib", + "rootDir": "src" + }, + "include": [ + "src/**/*.ts", + "../../__typings__/**/*.d.ts" + ], + "references": [ + { + "path": "../../config/config" + }, + { + "path": "../../config/normalize-registries" + }, + { + "path": "../../deps/graph-sequencer" + }, + { + "path": "../../exec/lifecycle" + }, + { + "path": "../../exec/pkg-requires-build" + }, + { + "path": "../../lockfile/types" + }, + { + "path": "../../lockfile/utils" + }, + { + "path": "../../lockfile/walker" + }, + { + "path": "../../packages/calc-dep-state" + }, + { + "path": "../../packages/constants" + }, + { + "path": "../../packages/core-loggers" + }, + { + "path": "../../packages/dependency-path" + }, + { + "path": "../../packages/error" + }, + { + "path": "../../packages/types" + }, + { + "path": "../../pkg-manager/get-context" + }, + { + "path": "../../pkg-manager/link-bins" + }, + { + "path": "../../pkg-manager/modules-yaml" + }, + { + "path": "../../pkg-manifest/read-package-json" + }, + { + "path": "../../store/cafs" + }, + { + "path": "../../store/index" + }, + { + "path": "../../store/store-connection-manager" + }, + { + "path": "../../store/store-controller-types" + }, + { + "path": "../../worker" + }, + { + "path": "../policy" + } + ] +} diff --git a/builder/policy/tsconfig.lint.json b/building/after-install/tsconfig.lint.json similarity index 100% rename from builder/policy/tsconfig.lint.json rename to building/after-install/tsconfig.lint.json diff --git a/builder/policy/CHANGELOG.md b/building/policy/CHANGELOG.md similarity index 100% rename from builder/policy/CHANGELOG.md rename to building/policy/CHANGELOG.md diff --git a/builder/policy/README.md b/building/policy/README.md similarity index 100% rename from builder/policy/README.md rename to building/policy/README.md diff --git a/builder/policy/package.json b/building/policy/package.json similarity index 79% rename from builder/policy/package.json rename to building/policy/package.json index cb57926198..4952fbf787 100644 --- a/builder/policy/package.json +++ b/building/policy/package.json @@ -1,6 +1,6 @@ { - "name": "@pnpm/builder.policy", - "version": "1000.0.0", + "name": "@pnpm/building.policy", + "version": "1000.0.0-0", "description": "Create a function for filtering out dependencies that are not allowed to be built", "keywords": [ "pnpm", @@ -8,8 +8,8 @@ ], "license": "MIT", "funding": "https://opencollective.com/pnpm", - "repository": "https://github.com/pnpm/pnpm/tree/main/builder/policy", - "homepage": "https://github.com/pnpm/pnpm/tree/main/builder/policy#readme", + "repository": "https://github.com/pnpm/pnpm/tree/main/building/policy", + "homepage": "https://github.com/pnpm/pnpm/tree/main/building/policy#readme", "bugs": { "url": "https://github.com/pnpm/pnpm/issues" }, @@ -35,7 +35,7 @@ "@pnpm/types": "workspace:*" }, "devDependencies": { - "@pnpm/builder.policy": "workspace:*" + "@pnpm/building.policy": "workspace:*" }, "engines": { "node": ">=22.13" diff --git a/builder/policy/src/index.ts b/building/policy/src/index.ts similarity index 100% rename from builder/policy/src/index.ts rename to building/policy/src/index.ts diff --git a/builder/policy/test/index.ts b/building/policy/test/index.ts similarity index 95% rename from builder/policy/test/index.ts rename to building/policy/test/index.ts index 63cdd18125..e3a4691e4e 100644 --- a/builder/policy/test/index.ts +++ b/building/policy/test/index.ts @@ -1,4 +1,4 @@ -import { createAllowBuildFunction } from '@pnpm/builder.policy' +import { createAllowBuildFunction } from '@pnpm/building.policy' it('should allowBuilds with true value', () => { const allowBuild = createAllowBuildFunction({ diff --git a/builder/policy/test/onlyBuild.json b/building/policy/test/onlyBuild.json similarity index 100% rename from builder/policy/test/onlyBuild.json rename to building/policy/test/onlyBuild.json diff --git a/builder/policy/test/tsconfig.json b/building/policy/test/tsconfig.json similarity index 100% rename from builder/policy/test/tsconfig.json rename to building/policy/test/tsconfig.json diff --git a/builder/policy/tsconfig.json b/building/policy/tsconfig.json similarity index 100% rename from builder/policy/tsconfig.json rename to building/policy/tsconfig.json diff --git a/building/policy/tsconfig.lint.json b/building/policy/tsconfig.lint.json new file mode 100644 index 0000000000..1bbe711971 --- /dev/null +++ b/building/policy/tsconfig.lint.json @@ -0,0 +1,8 @@ +{ + "extends": "./tsconfig.json", + "include": [ + "src/**/*.ts", + "test/**/*.ts", + "../../__typings__/**/*.d.ts" + ] +} diff --git a/exec/plugin-commands-rebuild/package.json b/exec/plugin-commands-rebuild/package.json index f958fac61f..0fbef5b657 100644 --- a/exec/plugin-commands-rebuild/package.json +++ b/exec/plugin-commands-rebuild/package.json @@ -32,59 +32,35 @@ "compile": "tsgo --build && pnpm run lint --fix" }, "dependencies": { - "@pnpm/builder.policy": "workspace:*", - "@pnpm/calc-dep-state": "workspace:*", + "@pnpm/building.after-install": "workspace:*", "@pnpm/cli-utils": "workspace:*", "@pnpm/common-cli-options-help": "workspace:*", "@pnpm/config": "workspace:*", - "@pnpm/constants": "workspace:*", - "@pnpm/core-loggers": "workspace:*", - "@pnpm/dependency-path": "workspace:*", - "@pnpm/deps.graph-sequencer": "workspace:*", - "@pnpm/error": "workspace:*", - "@pnpm/exec.pkg-requires-build": "workspace:*", - "@pnpm/get-context": "workspace:*", - "@pnpm/lifecycle": "workspace:*", - "@pnpm/link-bins": "workspace:*", - "@pnpm/lockfile.types": "workspace:*", - "@pnpm/lockfile.utils": "workspace:*", - "@pnpm/lockfile.walker": "workspace:*", - "@pnpm/modules-yaml": "workspace:*", - "@pnpm/normalize-registries": "workspace:*", - "@pnpm/npm-package-arg": "catalog:", - "@pnpm/read-package-json": "workspace:*", "@pnpm/sort-packages": "workspace:*", "@pnpm/store-connection-manager": "workspace:*", - "@pnpm/store-controller-types": "workspace:*", - "@pnpm/store.cafs": "workspace:*", - "@pnpm/store.index": "workspace:*", "@pnpm/types": "workspace:*", - "@pnpm/workspace.find-packages": "workspace:*", - "load-json-file": "catalog:", - "memoize": "catalog:", "p-limit": "catalog:", "ramda": "catalog:", - "render-help": "catalog:", - "run-groups": "catalog:", - "semver": "catalog:" + "render-help": "catalog:" }, "peerDependencies": { - "@pnpm/logger": "catalog:", - "@pnpm/worker": "workspace:^" + "@pnpm/logger": "catalog:" }, "devDependencies": { "@jest/globals": "catalog:", "@pnpm/assert-project": "workspace:*", + "@pnpm/constants": "workspace:*", "@pnpm/crypto.object-hasher": "workspace:*", "@pnpm/logger": "workspace:*", "@pnpm/plugin-commands-rebuild": "workspace:*", "@pnpm/prepare": "workspace:*", "@pnpm/registry-mock": "catalog:", + "@pnpm/store.cafs": "workspace:*", + "@pnpm/store.index": "workspace:*", "@pnpm/test-fixtures": "workspace:*", "@pnpm/test-ipc-server": "workspace:*", "@pnpm/workspace.filter-packages-from-dir": "workspace:*", "@types/ramda": "catalog:", - "@types/semver": "catalog:", "execa": "catalog:", "write-yaml-file": "catalog:" }, diff --git a/exec/plugin-commands-rebuild/src/index.ts b/exec/plugin-commands-rebuild/src/index.ts index b40f98e540..0a935a9958 100644 --- a/exec/plugin-commands-rebuild/src/index.ts +++ b/exec/plugin-commands-rebuild/src/index.ts @@ -3,4 +3,3 @@ import * as rebuild from './rebuild.js' export { type RebuildCommandOpts } from './rebuild.js' export { rebuild } -export { rebuildProjects, rebuildSelectedPkgs } from './implementation/index.js' diff --git a/exec/plugin-commands-rebuild/src/rebuild.ts b/exec/plugin-commands-rebuild/src/rebuild.ts index 19ff6add8f..2e68aebf88 100644 --- a/exec/plugin-commands-rebuild/src/rebuild.ts +++ b/exec/plugin-commands-rebuild/src/rebuild.ts @@ -1,3 +1,7 @@ +import { + rebuildProjects, + rebuildSelectedPkgs, +} from '@pnpm/building.after-install' import { docsUrl, readProjectManifestOnly } from '@pnpm/cli-utils' import { FILTERING, UNIVERSAL_OPTIONS } from '@pnpm/common-cli-options-help' import { type Config, types as allTypes } from '@pnpm/config' @@ -9,10 +13,6 @@ import { import type { ProjectRootDir } from '@pnpm/types' import { pick } from 'ramda' import renderHelp from 'render-help' -import { - rebuildProjects, - rebuildSelectedPkgs, -} from './implementation/index.js' import { recursiveRebuild } from './recursive.js' export function rcOptionsTypes (): Record { diff --git a/exec/plugin-commands-rebuild/src/recursive.ts b/exec/plugin-commands-rebuild/src/recursive.ts index e303f2eacc..087a1feabc 100755 --- a/exec/plugin-commands-rebuild/src/recursive.ts +++ b/exec/plugin-commands-rebuild/src/recursive.ts @@ -1,5 +1,6 @@ import assert from 'assert' import util from 'util' +import { rebuildProjects as rebuildAll, type RebuildOptions, rebuildSelectedPkgs } from '@pnpm/building.after-install' import { type RecursiveSummary, throwOnCommandFail, @@ -14,7 +15,6 @@ import { sortPackages } from '@pnpm/sort-packages' import { createStoreController, type CreateStoreControllerOptions } from '@pnpm/store-connection-manager' import type { Project, ProjectManifest, ProjectRootDir } from '@pnpm/types' import pLimit from 'p-limit' -import { rebuildProjects as rebuildAll, type RebuildOptions, rebuildSelectedPkgs } from './implementation/index.js' type RecursiveRebuildOpts = CreateStoreControllerOptions & Pick