yeoman-environment 4.1.3 → 4.2.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/dist/commit.js CHANGED
@@ -1,9 +1,7 @@
1
1
  import { createConflicterTransform, createYoResolveTransform, forceYoFiles } from '@yeoman/conflicter';
2
2
  import createdLogger from 'debug';
3
3
  import { create as createMemFsEditor } from 'mem-fs-editor';
4
- // eslint-disable-next-line n/file-extension-in-import
5
4
  import { createCommitTransform } from 'mem-fs-editor/transform';
6
- // eslint-disable-next-line n/file-extension-in-import
7
5
  import { isFilePending } from 'mem-fs-editor/state';
8
6
  const debug = createdLogger('yeoman:environment:commit');
9
7
  /**
@@ -13,6 +13,12 @@ import { ComposedStore } from './composed-store.js';
13
13
  import Store from './store.js';
14
14
  import type YeomanCommand from './util/command.js';
15
15
  import { type LookupOptions } from './generator-lookup.js';
16
+ export type EnvironmentLookupOptions = LookupOptions & {
17
+ /** Add a scope to the namespace if there is no scope */
18
+ registerToScope?: string;
19
+ /** Customize the namespace to be registered */
20
+ customizeNamespace?: (ns?: string) => string;
21
+ };
16
22
  export type EnvironmentOptions = BaseEnvironmentOptions & Omit<TerminalAdapterOptions, 'promptModule'> & {
17
23
  adapter?: InputOutputAdapter;
18
24
  logCwd?: string;
@@ -178,9 +184,7 @@ export default class EnvironmentBase extends EventEmitter implements BaseEnviron
178
184
  * So this index file `node_modules/generator-dummy/lib/generators/yo/index.js` would be
179
185
  * registered as `dummy:yo` generator.
180
186
  */
181
- lookup(options?: LookupOptions & {
182
- registerToScope?: string;
183
- }): Promise<LookupGeneratorMeta[]>;
187
+ lookup(options?: EnvironmentLookupOptions): Promise<LookupGeneratorMeta[]>;
184
188
  /**
185
189
  * Verify if a package namespace already have been registered.
186
190
  *
@@ -9,7 +9,6 @@ import { FlyRepository } from 'fly-import';
9
9
  import createdLogger from 'debug';
10
10
  // @ts-expect-error grouped-queue don't have types
11
11
  import GroupedQueue from 'grouped-queue';
12
- // eslint-disable-next-line n/file-extension-in-import
13
12
  import { isFilePending } from 'mem-fs-editor/state';
14
13
  import { transform, filePipeline } from '@yeoman/transform';
15
14
  import { toNamespace } from '@yeoman/namespace';
@@ -417,7 +416,7 @@ export default class EnvironmentBase extends EventEmitter {
417
416
  * registered as `dummy:yo` generator.
418
417
  */
419
418
  async lookup(options) {
420
- const { registerToScope, lookups = this.lookups, ...remainingOptions } = options ?? { localOnly: false };
419
+ const { registerToScope, customizeNamespace = (ns) => ns, lookups = this.lookups, ...remainingOptions } = options ?? { localOnly: false };
421
420
  options = {
422
421
  ...remainingOptions,
423
422
  lookups,
@@ -429,11 +428,11 @@ export default class EnvironmentBase extends EventEmitter {
429
428
  // Scoped package
430
429
  repositoryPath = join(repositoryPath, '..');
431
430
  }
432
- let namespace = asNamespace(relative(repositoryPath, filePath), { lookups });
431
+ let namespace = customizeNamespace(asNamespace(relative(repositoryPath, filePath), { lookups }));
433
432
  try {
434
433
  const resolved = realpathSync(filePath);
435
434
  if (!namespace) {
436
- namespace = asNamespace(resolved, { lookups });
435
+ namespace = customizeNamespace(asNamespace(resolved, { lookups }));
437
436
  }
438
437
  if (registerToScope && !namespace.startsWith('@')) {
439
438
  namespace = `@${registerToScope}/${namespace}`;
@@ -1,5 +1,5 @@
1
1
  import { createHash } from 'node:crypto';
2
- import { join } from 'node:path';
2
+ import { join, resolve } from 'node:path';
3
3
  import { requireNamespace, toNamespace } from '@yeoman/namespace';
4
4
  import { flyImport } from 'fly-import';
5
5
  import { defaults, pick, uniq } from 'lodash-es';
@@ -293,10 +293,13 @@ class FullEnvironment extends EnvironmentBase {
293
293
  async run(args, options) {
294
294
  args = Array.isArray(args) ? args : splitArgsFromString(args);
295
295
  options = { ...options };
296
- const name = args.shift();
296
+ let name = args.shift();
297
297
  if (!name) {
298
298
  throw new Error('Must provide at least one argument, the generator namespace to invoke.');
299
299
  }
300
+ if (name.startsWith('.')) {
301
+ name = resolve(name);
302
+ }
300
303
  this.loadEnvironmentOptions(options);
301
304
  if (this.experimental && !this.getGeneratorMeta(name)) {
302
305
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yeoman-environment",
3
- "version": "4.1.3",
3
+ "version": "4.2.0",
4
4
  "description": "Handles the lifecyle and bootstrapping of generators in a specific environment",
5
5
  "keywords": [
6
6
  "development",
@@ -61,16 +61,18 @@
61
61
  "@yeoman/conflicter": "^2.0.0-alpha.2",
62
62
  "@yeoman/namespace": "^1.0.0",
63
63
  "@yeoman/transform": "^1.2.0",
64
+ "@yeoman/types": "^1.1.1",
64
65
  "arrify": "^3.0.0",
65
66
  "chalk": "^5.3.0",
66
67
  "commander": "^11.1.0",
67
68
  "debug": "^4.3.4",
68
69
  "execa": "^8.0.1",
69
70
  "fly-import": "^0.4.0",
70
- "globby": "^13.2.2",
71
+ "globby": "^14.0.0",
71
72
  "grouped-queue": "^2.0.0",
72
73
  "locate-path": "^7.2.0",
73
74
  "lodash-es": "^4.17.21",
75
+ "mem-fs": "^4.0.0",
74
76
  "mem-fs-editor": "^11.0.0",
75
77
  "semver": "^7.5.4",
76
78
  "slash": "^5.1.0",