enablement-build-manifest 1.8.2 → 1.8.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "enablement-build-manifest",
3
- "version": "1.8.2",
3
+ "version": "1.8.7",
4
4
  "description": "T8is builds a dependency tree.",
5
5
  "type": "module",
6
6
  "module": "./index.mjs",
package/src/manifest.mjs CHANGED
@@ -4,7 +4,7 @@ import YAML from 'yaml'
4
4
  import path from 'path';
5
5
 
6
6
  import { detectCicdType } from './detect.mjs';
7
- import { resolveWorkspaceChildren, buildPackageJsonGlob, excludeChildren } from './workspace.mjs';
7
+ import { resolveWorkspaceChildren, buildPackageJsonGlob, excludeChildren, resolvePackageFolder } from './workspace.mjs';
8
8
  import { resolveHashFilePath, writeHashFile } from './hashFile.mjs';
9
9
 
10
10
  // manifest.json's current schema version. Every `--save` run converts the
@@ -78,7 +78,7 @@ export const generateManifest = async (options) => {
78
78
  versions[pkgJson.name] = pkgJson.version;
79
79
  dependents[pkgJson.name] = []; // Initialize reverse dependency map
80
80
  const folderName = path.basename(path.dirname(pkgPath));
81
- const packageFolder = path.relative(process.cwd(), path.dirname(path.dirname(pkgPath)));
81
+ const packageFolder = resolvePackageFolder(pkgPath);
82
82
  if (pkgJson['.cicd']) {
83
83
  const cicdEntry = { ...pkgJson['.cicd'] };
84
84
  delete cicdEntry.templates;
@@ -132,7 +132,7 @@ export const generateManifest = async (options) => {
132
132
  if (!cicd[pkgName].folderName)
133
133
  cicd[pkgName].folderName = path.basename(path.dirname(pkgPath));
134
134
  if (!cicd[pkgName].packageFolder)
135
- cicd[pkgName].packageFolder = path.relative(process.cwd(), path.dirname(path.dirname(pkgPath)));
135
+ cicd[pkgName].packageFolder = resolvePackageFolder(pkgPath);
136
136
  }
137
137
  });
138
138
 
package/src/workspace.mjs CHANGED
@@ -100,3 +100,8 @@ export function buildPackageJsonGlob(children) {
100
100
  if (roots.length === 0) return '*/**/package.json';
101
101
  return roots.length > 1 ? `{${roots.join(',')}}/**/package.json` : `${roots[0]}/**/package.json`;
102
102
  }
103
+
104
+ // Resolve the workspace-relative package folder from a package.json path.
105
+ export function resolvePackageFolder(packageJsonPath, workspaceRoot = process.cwd()) {
106
+ return path.relative(workspaceRoot, path.dirname(path.dirname(packageJsonPath)));
107
+ }
@@ -8,6 +8,7 @@ import {
8
8
  resolveWorkspaceChildren,
9
9
  buildPackageJsonGlob,
10
10
  excludeChildren,
11
+ resolvePackageFolder,
11
12
  } from '../src/workspace.mjs';
12
13
 
13
14
  describe('parseWorkspacePatterns', () => {
@@ -175,3 +176,10 @@ describe('excludeChildren', () => {
175
176
  expect(excludeChildren('packages,apps', ['packages', 'apps'])).toBeNull();
176
177
  });
177
178
  });
179
+
180
+ describe('resolvePackageFolder', () => {
181
+ it('returns the workspace-relative directory containing package roots', () => {
182
+ expect(resolvePackageFolder('/repo/packages/example/package.json', '/repo')).toBe('packages');
183
+ expect(resolvePackageFolder('/repo/apps/example/package.json', '/repo')).toBe('apps');
184
+ });
185
+ });