feat(js): adding simpleName option to library generator (#16025)
This commit is contained in:
parent
43a7d770fa
commit
fbf8d9c99f
@ -127,6 +127,11 @@
|
|||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"description": "Generate a library with a minimal setup. No README.md generated.",
|
"description": "Generate a library with a minimal setup. No README.md generated.",
|
||||||
"default": false
|
"default": false
|
||||||
|
},
|
||||||
|
"simpleName": {
|
||||||
|
"description": "Don't include the directory in the generated file name.",
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": ["name"],
|
"required": ["name"],
|
||||||
|
|||||||
@ -183,7 +183,6 @@ describe('lib', () => {
|
|||||||
name: 'myLib2',
|
name: 'myLib2',
|
||||||
directory: 'myDir',
|
directory: 'myDir',
|
||||||
tags: 'one,two',
|
tags: 'one,two',
|
||||||
simpleModuleName: true,
|
|
||||||
});
|
});
|
||||||
projects = Object.fromEntries(getProjects(tree));
|
projects = Object.fromEntries(getProjects(tree));
|
||||||
expect(projects).toMatchObject({
|
expect(projects).toMatchObject({
|
||||||
@ -1147,4 +1146,20 @@ describe('lib', () => {
|
|||||||
expect(project.targets.build.options.assets).toEqual([]);
|
expect(project.targets.build.options.assets).toEqual([]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('--simpleName', () => {
|
||||||
|
it('should generate a simple name', async () => {
|
||||||
|
await libraryGenerator(tree, {
|
||||||
|
...defaultOptions,
|
||||||
|
name: 'myLib',
|
||||||
|
simpleName: true,
|
||||||
|
directory: 'web',
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(tree.read('libs/web/my-lib/src/index.ts', 'utf-8')).toContain(
|
||||||
|
`export * from './lib/my-lib';`
|
||||||
|
);
|
||||||
|
expect(tree.exists('libs/web/my-lib/src/lib/my-lib.ts')).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -487,7 +487,7 @@ function normalizeOptions(
|
|||||||
? name
|
? name
|
||||||
: projectDirectory.replace(new RegExp('/', 'g'), '-');
|
: projectDirectory.replace(new RegExp('/', 'g'), '-');
|
||||||
const fileName = getCaseAwareFileName({
|
const fileName = getCaseAwareFileName({
|
||||||
fileName: options.simpleModuleName ? name : projectName,
|
fileName: options.simpleName ? name : projectName,
|
||||||
pascalCaseFiles: options.pascalCaseFiles,
|
pascalCaseFiles: options.pascalCaseFiles,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -127,6 +127,11 @@
|
|||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"description": "Generate a library with a minimal setup. No README.md generated.",
|
"description": "Generate a library with a minimal setup. No README.md generated.",
|
||||||
"default": false
|
"default": false
|
||||||
|
},
|
||||||
|
"simpleName": {
|
||||||
|
"description": "Don't include the directory in the generated file name.",
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": ["name"],
|
"required": ["name"],
|
||||||
|
|||||||
2
packages/js/src/utils/schema.d.ts
vendored
2
packages/js/src/utils/schema.d.ts
vendored
@ -11,7 +11,6 @@ export interface LibraryGeneratorSchema {
|
|||||||
directory?: string;
|
directory?: string;
|
||||||
skipFormat?: boolean;
|
skipFormat?: boolean;
|
||||||
tags?: string;
|
tags?: string;
|
||||||
simpleModuleName?: boolean;
|
|
||||||
skipTsConfig?: boolean;
|
skipTsConfig?: boolean;
|
||||||
includeBabelRc?: boolean;
|
includeBabelRc?: boolean;
|
||||||
unitTestRunner?: 'jest' | 'vitest' | 'none';
|
unitTestRunner?: 'jest' | 'vitest' | 'none';
|
||||||
@ -30,6 +29,7 @@ export interface LibraryGeneratorSchema {
|
|||||||
skipTypeCheck?: boolean;
|
skipTypeCheck?: boolean;
|
||||||
minimal?: boolean;
|
minimal?: boolean;
|
||||||
rootProject?: boolean;
|
rootProject?: boolean;
|
||||||
|
simpleName?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ExecutorOptions {
|
export interface ExecutorOptions {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user