@pnpm/workspace.state 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015-2016 Rico Sta. Cruz and other contributors
4
+ Copyright (c) 2016-2024 Zoltan Kochan and other contributors
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,17 @@
1
+ # @pnpm/workspace.state
2
+
3
+ > Track the list of actual paths of workspace packages in a cache.
4
+
5
+ <!--@shields('npm')-->
6
+ [![npm version](https://img.shields.io/npm/v/@pnpm/workspace.state.svg)](https://www.npmjs.com/package/@pnpm/workspace.state)
7
+ <!--/@-->
8
+
9
+ ## Installation
10
+
11
+ ```sh
12
+ pnpm add @pnpm/workspace.state
13
+ ```
14
+
15
+ ## License
16
+
17
+ MIT
@@ -0,0 +1,8 @@
1
+ import { type Catalogs } from '@pnpm/catalogs.types';
2
+ import { type WorkspaceState, type ProjectsList } from './types';
3
+ export interface CreateWorkspaceStateOptions {
4
+ allProjects: ProjectsList;
5
+ catalogs: Catalogs | undefined;
6
+ lastValidatedTimestamp: number;
7
+ }
8
+ export declare const createWorkspaceState: (opts: CreateWorkspaceStateOptions) => WorkspaceState;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createWorkspaceState = void 0;
4
+ const createWorkspaceState = (opts) => ({
5
+ catalogs: opts.catalogs,
6
+ lastValidatedTimestamp: opts.lastValidatedTimestamp,
7
+ projectRootDirs: opts.allProjects.map(project => project.rootDir).sort(),
8
+ });
9
+ exports.createWorkspaceState = createWorkspaceState;
10
+ //# sourceMappingURL=createWorkspaceState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createWorkspaceState.js","sourceRoot":"","sources":["../src/createWorkspaceState.ts"],"names":[],"mappings":";;;AASO,MAAM,oBAAoB,GAAG,CAAC,IAAiC,EAAkB,EAAE,CAAC,CAAC;IAC1F,QAAQ,EAAE,IAAI,CAAC,QAAQ;IACvB,sBAAsB,EAAE,IAAI,CAAC,sBAAsB;IACnD,eAAe,EAAE,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE;CACzE,CAAC,CAAA;AAJW,QAAA,oBAAoB,wBAI/B"}
@@ -0,0 +1 @@
1
+ export declare const getFilePath: (workspaceDir: string) => string;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getFilePath = void 0;
7
+ const path_1 = __importDefault(require("path"));
8
+ const getFilePath = (workspaceDir) => path_1.default.join(workspaceDir, 'node_modules', '.pnpm-workspace-state.json');
9
+ exports.getFilePath = getFilePath;
10
+ //# sourceMappingURL=filePath.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filePath.js","sourceRoot":"","sources":["../src/filePath.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAuB;AAEhB,MAAM,WAAW,GAAG,CAAC,YAAoB,EAAU,EAAE,CAC1D,cAAI,CAAC,IAAI,CAAC,YAAY,EAAE,cAAc,EAAE,4BAA4B,CAAC,CAAA;AAD1D,QAAA,WAAW,eAC+C"}
package/lib/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export { loadWorkspaceState } from './loadWorkspaceState';
2
+ export { type UpdateWorkspaceStateOptions, updateWorkspaceState } from './updateWorkspaceState';
3
+ export { type WorkspaceState, type ProjectsList } from './types';
package/lib/index.js ADDED
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateWorkspaceState = exports.loadWorkspaceState = void 0;
4
+ var loadWorkspaceState_1 = require("./loadWorkspaceState");
5
+ Object.defineProperty(exports, "loadWorkspaceState", { enumerable: true, get: function () { return loadWorkspaceState_1.loadWorkspaceState; } });
6
+ var updateWorkspaceState_1 = require("./updateWorkspaceState");
7
+ Object.defineProperty(exports, "updateWorkspaceState", { enumerable: true, get: function () { return updateWorkspaceState_1.updateWorkspaceState; } });
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,2DAAyD;AAAhD,wHAAA,kBAAkB,OAAA;AAC3B,+DAA+F;AAApD,4HAAA,oBAAoB,OAAA"}
@@ -0,0 +1,2 @@
1
+ import { type WorkspaceState } from './types';
2
+ export declare function loadWorkspaceState(workspaceDir: string): WorkspaceState | undefined;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.loadWorkspaceState = loadWorkspaceState;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const util_1 = __importDefault(require("util"));
9
+ const logger_1 = require("@pnpm/logger");
10
+ const filePath_1 = require("./filePath");
11
+ function loadWorkspaceState(workspaceDir) {
12
+ logger_1.logger.debug({ msg: 'loading workspace state' });
13
+ const cacheFile = (0, filePath_1.getFilePath)(workspaceDir);
14
+ let cacheFileContent;
15
+ try {
16
+ cacheFileContent = fs_1.default.readFileSync(cacheFile, 'utf-8');
17
+ }
18
+ catch (error) {
19
+ if (util_1.default.types.isNativeError(error) && 'code' in error && error.code === 'ENOENT') {
20
+ return undefined;
21
+ }
22
+ throw error;
23
+ }
24
+ return JSON.parse(cacheFileContent);
25
+ }
26
+ //# sourceMappingURL=loadWorkspaceState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadWorkspaceState.js","sourceRoot":"","sources":["../src/loadWorkspaceState.ts"],"names":[],"mappings":";;;;;AAMA,gDAaC;AAnBD,4CAAmB;AACnB,gDAAuB;AACvB,yCAAqC;AACrC,yCAAwC;AAGxC,SAAgB,kBAAkB,CAAE,YAAoB;IACtD,eAAM,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,yBAAyB,EAAE,CAAC,CAAA;IAChD,MAAM,SAAS,GAAG,IAAA,sBAAW,EAAC,YAAY,CAAC,CAAA;IAC3C,IAAI,gBAAwB,CAAA;IAC5B,IAAI,CAAC;QACH,gBAAgB,GAAG,YAAE,CAAC,YAAY,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;IACxD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,cAAI,CAAC,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,MAAM,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAClF,OAAO,SAAS,CAAA;QAClB,CAAC;QACD,MAAM,KAAK,CAAA;IACb,CAAC;IACD,OAAO,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAmB,CAAA;AACvD,CAAC"}
package/lib/types.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ import { type Catalogs } from '@pnpm/catalogs.types';
2
+ import { type Project, type ProjectRootDir } from '@pnpm/types';
3
+ export type ProjectsList = Array<Pick<Project, 'rootDir'>>;
4
+ export interface WorkspaceState {
5
+ catalogs: Catalogs | undefined;
6
+ lastValidatedTimestamp: number;
7
+ projectRootDirs: ProjectRootDir[];
8
+ }
package/lib/types.js ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,9 @@
1
+ import { type Catalogs } from '@pnpm/catalogs.types';
2
+ import { type ProjectsList } from './types';
3
+ export interface UpdateWorkspaceStateOptions {
4
+ allProjects: ProjectsList;
5
+ catalogs: Catalogs | undefined;
6
+ lastValidatedTimestamp: number;
7
+ workspaceDir: string;
8
+ }
9
+ export declare function updateWorkspaceState(opts: UpdateWorkspaceStateOptions): Promise<void>;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.updateWorkspaceState = updateWorkspaceState;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const logger_1 = require("@pnpm/logger");
10
+ const filePath_1 = require("./filePath");
11
+ const createWorkspaceState_1 = require("./createWorkspaceState");
12
+ async function updateWorkspaceState(opts) {
13
+ logger_1.logger.debug({ msg: 'updating workspace state' });
14
+ const workspaceState = (0, createWorkspaceState_1.createWorkspaceState)(opts);
15
+ const workspaceStateJSON = JSON.stringify(workspaceState, undefined, 2) + '\n';
16
+ const cacheFile = (0, filePath_1.getFilePath)(opts.workspaceDir);
17
+ await fs_1.default.promises.mkdir(path_1.default.dirname(cacheFile), { recursive: true });
18
+ await fs_1.default.promises.writeFile(cacheFile, workspaceStateJSON);
19
+ }
20
+ //# sourceMappingURL=updateWorkspaceState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"updateWorkspaceState.js","sourceRoot":"","sources":["../src/updateWorkspaceState.ts"],"names":[],"mappings":";;;;;AAeA,oDAOC;AAtBD,4CAAmB;AACnB,gDAAuB;AAEvB,yCAAqC;AACrC,yCAAwC;AACxC,iEAA6D;AAUtD,KAAK,UAAU,oBAAoB,CAAE,IAAiC;IAC3E,eAAM,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,0BAA0B,EAAE,CAAC,CAAA;IACjD,MAAM,cAAc,GAAG,IAAA,2CAAoB,EAAC,IAAI,CAAC,CAAA;IACjD,MAAM,kBAAkB,GAAG,IAAI,CAAC,SAAS,CAAC,cAAc,EAAE,SAAS,EAAE,CAAC,CAAC,GAAG,IAAI,CAAA;IAC9E,MAAM,SAAS,GAAG,IAAA,sBAAW,EAAC,IAAI,CAAC,YAAY,CAAC,CAAA;IAChD,MAAM,YAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAI,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IACrE,MAAM,YAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,SAAS,EAAE,kBAAkB,CAAC,CAAA;AAC5D,CAAC"}
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@pnpm/workspace.state",
3
+ "version": "0.0.0",
4
+ "description": "Track the list of actual paths of workspace packages in a cache",
5
+ "main": "lib/index.js",
6
+ "types": "lib/index.d.ts",
7
+ "engines": {
8
+ "node": ">=18.12"
9
+ },
10
+ "files": [
11
+ "lib",
12
+ "!*.map"
13
+ ],
14
+ "repository": "https://github.com/pnpm/pnpm/blob/main/workspace/state",
15
+ "keywords": [
16
+ "pnpm10",
17
+ "pnpm",
18
+ "mtime"
19
+ ],
20
+ "license": "MIT",
21
+ "bugs": {
22
+ "url": "https://github.com/pnpm/pnpm/issues"
23
+ },
24
+ "homepage": "https://github.com/pnpm/pnpm/blob/main/workspace/state#readme",
25
+ "funding": "https://opencollective.com/pnpm",
26
+ "dependencies": {
27
+ "ramda": "npm:@pnpm/ramda@0.28.1",
28
+ "@pnpm/logger": "5.2.0",
29
+ "@pnpm/catalogs.types": "0.1.0",
30
+ "@pnpm/types": "12.2.0"
31
+ },
32
+ "devDependencies": {
33
+ "@pnpm/prepare": "0.0.105",
34
+ "@pnpm/workspace.state": "0.0.0"
35
+ },
36
+ "exports": {
37
+ ".": "./lib/index.js"
38
+ },
39
+ "jest": {
40
+ "preset": "@pnpm/jest-config"
41
+ },
42
+ "scripts": {
43
+ "test": "pnpm run compile && pnpm run _test",
44
+ "_test": "jest",
45
+ "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"",
46
+ "compile": "tsc --build && pnpm run lint --fix"
47
+ }
48
+ }