@travetto/manifest 3.0.0-rc.11 → 3.0.0-rc.12

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/bin/context.js CHANGED
@@ -101,6 +101,8 @@ export async function getManifestContext(folder) {
101
101
 
102
102
  const moduleType = (await $getPkg(workspacePath)).type ?? 'commonjs';
103
103
  const mainFolder = mainPath === workspacePath ? '' : mainPath.replace(`${workspacePath}/`, '');
104
+ /** @type {'yarn'|'npm'} */
105
+ const packageManager = await fs.stat(path.resolve(workspacePath, 'yarn.lock')).then(() => 'yarn', () => 'npm');
104
106
 
105
107
  const res = {
106
108
  moduleType,
@@ -110,7 +112,8 @@ export async function getManifestContext(folder) {
110
112
  monoRepo,
111
113
  outputFolder,
112
114
  toolFolder: '.trv_build',
113
- compilerFolder: '.trv_compiler'
115
+ compilerFolder: '.trv_compiler',
116
+ packageManager
114
117
  };
115
118
  return res;
116
119
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/manifest",
3
- "version": "3.0.0-rc.11",
3
+ "version": "3.0.0-rc.12",
4
4
  "description": "Manifest support",
5
5
  "keywords": [
6
6
  "path",
@@ -305,6 +305,7 @@ export class ManifestIndex {
305
305
  return this.getLocalModules().flatMap(x =>
306
306
  ((!this.manifest.monoRepo || x.sourcePath !== this.manifest.workspacePath) ?
307
307
  [x.sourcePath] : [...Object.keys(x.files)].filter(y => !y.startsWith('$')).map(y => path.resolve(x.sourcePath, y))
308
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
308
309
  ).map(f => [f, path.resolve(x.sourceFolder)] as [string, string])
309
310
  );
310
311
  }
package/src/package.ts CHANGED
@@ -179,9 +179,25 @@ export class PackageUtil {
179
179
  try {
180
180
  return JSON.parse(await fs.readFile(cache, 'utf8'));
181
181
  } catch {
182
- const text = execSync('npm query .workspace', { cwd: rootPath, encoding: 'utf8', env: { PATH: process.env.PATH, NODE_PATH: process.env.NODE_PATH } });
183
- const res: { location: string, name: string }[] = JSON.parse(text);
184
- const out = this.#workspaces[rootPath] = res.map(d => ({ sourcePath: d.location, name: d.name }));
182
+ let out: PackageWorkspaceEntry[];
183
+ switch (ctx.packageManager) {
184
+ case 'npm': {
185
+ const text = execSync('npm query .workspace', { cwd: rootPath, encoding: 'utf8', env: { PATH: process.env.PATH, NODE_PATH: process.env.NODE_PATH } });
186
+ out = JSON.parse(text)
187
+ .map((d: { location: string, name: string }) => ({ sourcePath: d.location, name: d.name }));
188
+ break;
189
+ }
190
+ case 'yarn': {
191
+ const text = execSync('yarn -s workspaces info', { cwd: rootPath, encoding: 'utf8', env: { PATH: process.env.PATH, NODE_PATH: process.env.NODE_PATH } });
192
+ out = Object.entries<{ location: string }>(JSON.parse(text))
193
+ .map(([name, { location }]) => ({ sourcePath: location, name }));
194
+ break;
195
+ }
196
+ default: throw new Error(`Unknown package manager: ${ctx.packageManager}`);
197
+ }
198
+
199
+ this.#workspaces[rootPath] = out;
200
+
185
201
  await fs.writeFile(cache, JSON.stringify(out), 'utf8');
186
202
  }
187
203
  }
package/src/types.ts CHANGED
@@ -34,6 +34,7 @@ export type ManifestContext = {
34
34
  compilerFolder: string;
35
35
  monoRepo?: boolean;
36
36
  moduleType: 'module' | 'commonjs';
37
+ packageManager: 'yarn' | 'npm';
37
38
  };
38
39
 
39
40
  export type ManifestRoot = ManifestContext & {
package/src/watch.ts CHANGED
@@ -22,7 +22,11 @@ async function getWatcher(): Promise<typeof import('@parcel/watcher')> {
22
22
  * @param onEvent
23
23
  * @private
24
24
  */
25
- export async function watchFolders(folders: string[] | [folder: string, targetFolder: string][], onEvent: WatchEventListener, config: WatchConfig = {}): Promise<() => Promise<void>> {
25
+ export async function watchFolders(
26
+ folders: string[] | [folder: string, targetFolder: string][],
27
+ onEvent: WatchEventListener,
28
+ config: WatchConfig = {}
29
+ ): Promise<() => Promise<void>> {
26
30
  const lib = await getWatcher();
27
31
  const createMissing = config.createMissing ?? false;
28
32
  const validFolders = new Set(folders.map(x => typeof x === 'string' ? x : x[0]));