typesync 0.13.4 → 0.14.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.
Files changed (57) hide show
  1. package/README.md +23 -25
  2. package/bin/typesync +2 -2
  3. package/{lib → dist}/cli-util.d.ts +17 -17
  4. package/{lib → dist}/cli.d.ts +2 -2
  5. package/dist/cli.js +300 -0
  6. package/dist/cli.js.map +1 -0
  7. package/dist/config-service.d.ts +11 -0
  8. package/dist/globber.d.ts +15 -0
  9. package/dist/index.d.ts +4 -0
  10. package/dist/index.js +3 -0
  11. package/dist/package-json-file-service.d.ts +15 -0
  12. package/dist/package-source.d.ts +25 -0
  13. package/dist/type-syncer-D93oGCvC.js +315 -0
  14. package/dist/type-syncer-D93oGCvC.js.map +1 -0
  15. package/dist/type-syncer.d.ts +13 -0
  16. package/dist/types.d.ts +103 -0
  17. package/dist/util.d.ts +46 -0
  18. package/dist/versioning.d.ts +14 -0
  19. package/dist/workspace-resolver.d.ts +81 -0
  20. package/package.json +41 -66
  21. package/lib/cli-util.js +0 -74
  22. package/lib/cli-util.js.map +0 -1
  23. package/lib/cli.js +0 -141
  24. package/lib/cli.js.map +0 -1
  25. package/lib/config-service.d.ts +0 -11
  26. package/lib/config-service.js +0 -61
  27. package/lib/config-service.js.map +0 -1
  28. package/lib/fs-utils.js +0 -28
  29. package/lib/fs-utils.js.map +0 -1
  30. package/lib/globber.d.ts +0 -15
  31. package/lib/globber.js +0 -43
  32. package/lib/globber.js.map +0 -1
  33. package/lib/index.d.ts +0 -4
  34. package/lib/index.js +0 -21
  35. package/lib/index.js.map +0 -1
  36. package/lib/package-json-file-service.d.ts +0 -15
  37. package/lib/package-json-file-service.js +0 -48
  38. package/lib/package-json-file-service.js.map +0 -1
  39. package/lib/package-source.d.ts +0 -25
  40. package/lib/package-source.js +0 -49
  41. package/lib/package-source.js.map +0 -1
  42. package/lib/type-syncer.d.ts +0 -13
  43. package/lib/type-syncer.js +0 -239
  44. package/lib/type-syncer.js.map +0 -1
  45. package/lib/types.d.ts +0 -103
  46. package/lib/types.js +0 -14
  47. package/lib/types.js.map +0 -1
  48. package/lib/util.d.ts +0 -53
  49. package/lib/util.js +0 -142
  50. package/lib/util.js.map +0 -1
  51. package/lib/versioning.d.ts +0 -14
  52. package/lib/versioning.js +0 -48
  53. package/lib/versioning.js.map +0 -1
  54. package/lib/workspace-resolver.d.ts +0 -79
  55. package/lib/workspace-resolver.js +0 -70
  56. package/lib/workspace-resolver.js.map +0 -1
  57. /package/{lib → dist}/fs-utils.d.ts +0 -0
@@ -1,14 +0,0 @@
1
- /**
2
- * Version descriptor for versions returned in remote package info.
3
- */
4
- export interface IPackageVersionInfo {
5
- version: string;
6
- containsInternalTypings: boolean;
7
- }
8
- /**
9
- * Gets the closest matching package version info.
10
- *
11
- * @param availableVersions
12
- * @param version
13
- */
14
- export declare function getClosestMatchingVersion(availableVersions: Array<IPackageVersionInfo>, version: string): IPackageVersionInfo;
package/lib/versioning.js DELETED
@@ -1,48 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getClosestMatchingVersion = getClosestMatchingVersion;
4
- const semver_1 = require("semver");
5
- /**
6
- * Gets the closest matching package version info.
7
- *
8
- * @param availableVersions
9
- * @param version
10
- */
11
- function getClosestMatchingVersion(availableVersions, version) {
12
- const parsedVersion = parseVersion(version);
13
- if (!parsedVersion) {
14
- return availableVersions[0];
15
- }
16
- const bestMatch = availableVersions.find((v) => {
17
- const parsedAvailableVersion = parseVersion(v.version);
18
- if (!parsedAvailableVersion) {
19
- return false;
20
- }
21
- if (parsedVersion.major !== parsedAvailableVersion.major) {
22
- return false;
23
- }
24
- if (parsedVersion.minor !== parsedAvailableVersion.minor) {
25
- return false;
26
- }
27
- return true;
28
- });
29
- return bestMatch ?? availableVersions[0];
30
- }
31
- /**
32
- * Parses the version if possible.
33
- *
34
- * @param version
35
- * @returns
36
- */
37
- function parseVersion(version) {
38
- return (0, semver_1.parse)(cleanVersion(version));
39
- }
40
- /**
41
- * Cleans the version of any semver range specifiers.
42
- * @param version
43
- * @returns
44
- */
45
- function cleanVersion(version) {
46
- return version.replace(/^[\^~=\s]/, '');
47
- }
48
- //# sourceMappingURL=versioning.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"versioning.js","sourceRoot":"","sources":["../src/versioning.ts"],"names":[],"mappings":";;AAgBA,8DA2BC;AA3CD,mCAA8B;AAU9B;;;;;GAKG;AACH,SAAgB,yBAAyB,CACvC,iBAA6C,EAC7C,OAAe;IAEf,MAAM,aAAa,GAAG,YAAY,CAAC,OAAO,CAAC,CAAA;IAC3C,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,OAAO,iBAAiB,CAAC,CAAC,CAAC,CAAA;IAC7B,CAAC;IAED,MAAM,SAAS,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE;QAC7C,MAAM,sBAAsB,GAAG,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,CAAA;QACtD,IAAI,CAAC,sBAAsB,EAAE,CAAC;YAC5B,OAAO,KAAK,CAAA;QACd,CAAC;QAED,IAAI,aAAa,CAAC,KAAK,KAAK,sBAAsB,CAAC,KAAK,EAAE,CAAC;YACzD,OAAO,KAAK,CAAA;QACd,CAAC;QAED,IAAI,aAAa,CAAC,KAAK,KAAK,sBAAsB,CAAC,KAAK,EAAE,CAAC;YACzD,OAAO,KAAK,CAAA;QACd,CAAC;QAED,OAAO,IAAI,CAAA;IACb,CAAC,CAAC,CAAA;IAEF,OAAO,SAAS,IAAI,iBAAiB,CAAC,CAAC,CAAC,CAAA;AAC1C,CAAC;AAED;;;;;GAKG;AACH,SAAS,YAAY,CAAC,OAAe;IACnC,OAAO,IAAA,cAAK,EAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAA;AACrC,CAAC;AAED;;;;GAIG;AACH,SAAS,YAAY,CAAC,OAAe;IACnC,OAAO,OAAO,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAA;AACzC,CAAC"}
@@ -1,79 +0,0 @@
1
- import type * as fsUtils from './fs-utils';
2
- import { IGlobber } from './globber';
3
- import type { IPackageFile } from './types';
4
- /**
5
- * Service for fetching monorepo workspaces in a standardized format in package-manager-agnostic way.
6
- * It is used to allow syncing all types in a workspace when run from the root of a monorepo.
7
- */
8
- export interface IWorkspaceResolverService {
9
- /**
10
- * Reads, parses, and normalizes a workspaces configuration from the following files, in this order:
11
- * - `package.json` `workspaces` field, as an array of globs.
12
- * - `package.json` `workspaces` field, as an object with a `projects` field, which is an array of globs.
13
- * - `pnpm-workspace.yaml` `packages` field, as an array of globs.
14
- *
15
- * Path is relative to the current working directory.
16
- * Note that this returns a list of directories, not paths to the manifests themselves.
17
- */
18
- getWorkspaces(packageJson: IPackageFile, root: string, globber: IGlobber, ignored: IWorkspacesArray): Promise<IWorkspacesArray>;
19
- }
20
- /**
21
- * @example
22
- * ```json
23
- * "workspaces": [
24
- * "packages/*",
25
- * ]
26
- * ```
27
- */
28
- export type IWorkspacesArray = Array<string>;
29
- /**
30
- * @example
31
- * ```yaml
32
- * projects:
33
- * - 'packages/*'
34
- * ```
35
- */
36
- export interface IWorkspacesObject {
37
- packages: IWorkspacesArray;
38
- }
39
- /**
40
- * @see {@link IWorkspacesArray}
41
- */
42
- export type NpmWorkspacesConfig = IWorkspacesArray;
43
- /**
44
- * Yarn is a special snowflake.
45
- *
46
- * @example
47
- * ```json
48
- * "workspaces": {
49
- * "packages": [
50
- * "packages/*",
51
- * ],
52
- * "nohoist": []
53
- * }
54
- * ```
55
- */
56
- export type YarnWorkspacesConfig = IWorkspacesArray | (IWorkspacesObject & {
57
- nohoist?: Array<string>;
58
- });
59
- /**
60
- * The contents of a `pnpm-workspace.yaml` file.
61
- *
62
- * @example
63
- * ```yaml
64
- * packages:
65
- * - 'packages/*'
66
- * ```
67
- */
68
- export type PnpmWorkspacesConfig = IWorkspacesObject;
69
- /**
70
- * @see {@link IWorkspacesArray}
71
- */
72
- export type BunWorkspacesConfig = IWorkspacesArray;
73
- /**
74
- * Section in `package.json` representing workspaces.
75
- */
76
- export type IWorkspacesSection = NpmWorkspacesConfig | YarnWorkspacesConfig | BunWorkspacesConfig;
77
- export declare function createWorkspaceResolverService({ readFileContents, }: {
78
- readFileContents: typeof fsUtils.readFileContents;
79
- }): IWorkspaceResolverService;
@@ -1,70 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.createWorkspaceResolverService = createWorkspaceResolverService;
30
- const path = __importStar(require("node:path"));
31
- const js_yaml_1 = __importDefault(require("js-yaml"));
32
- const util_1 = require("./util");
33
- function createWorkspaceResolverService({ readFileContents, }) {
34
- return {
35
- getWorkspaces: async (packageJson, root, globber, ignored) => {
36
- const [manifests, ignoredWorkspaces] = await Promise.all([
37
- (async () => {
38
- const workspaces = await getWorkspaces(packageJson, root);
39
- const workspacesArray = (0, util_1.ensureWorkspacesArray)(workspaces);
40
- const globbedArrays = await Promise.all(workspacesArray.map(async (workspace) => await globber.glob(root, workspace)));
41
- return (0, util_1.uniq)(globbedArrays.flat());
42
- })(),
43
- (async () => {
44
- const ignoredWorkspacesArrays = await Promise.all(ignored.map(async (ignoredWorkspace) => await globber.glob(root, ignoredWorkspace)));
45
- return (0, util_1.uniq)(ignoredWorkspacesArrays.flat());
46
- })(),
47
- ]);
48
- return manifests.filter((manifest) => !ignoredWorkspaces.includes(manifest));
49
- },
50
- };
51
- async function getWorkspaces(packageJson, root) {
52
- const packageJsonWorkspaces = packageJson.workspaces;
53
- if (packageJsonWorkspaces !== undefined) {
54
- return packageJsonWorkspaces;
55
- }
56
- return await getPnpmWorkspaces(root);
57
- }
58
- async function getPnpmWorkspaces(root) {
59
- try {
60
- const filePath = path.relative(root, 'pnpm-workspace.yaml');
61
- const contents = await readFileContents(filePath);
62
- const pnpmWorkspaces = js_yaml_1.default.load(contents);
63
- return pnpmWorkspaces.packages;
64
- }
65
- catch {
66
- return undefined;
67
- }
68
- }
69
- }
70
- //# sourceMappingURL=workspace-resolver.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"workspace-resolver.js","sourceRoot":"","sources":["../src/workspace-resolver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgGA,wEA8DC;AA9JD,gDAAiC;AACjC,sDAA0B;AAG1B,iCAAoD;AA4FpD,SAAgB,8BAA8B,CAAC,EAC7C,gBAAgB,GAGjB;IACC,OAAO;QACL,aAAa,EAAE,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE;YAC3D,MAAM,CAAC,SAAS,EAAE,iBAAiB,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;gBACvD,CAAC,KAAK,IAAI,EAAE;oBACV,MAAM,UAAU,GAAG,MAAM,aAAa,CAAC,WAAW,EAAE,I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