Remove lerna considerations for calculating baseVersion
Signed-off-by: Min Kim <minkimcello@gmail.com>
This commit is contained in:
@@ -57,7 +57,7 @@ export default async () => {
|
||||
globals,
|
||||
codeOwnersFilePath,
|
||||
});
|
||||
const options = await populateOptions(prompts, template);
|
||||
const options = populateOptions(prompts, template);
|
||||
|
||||
const tempDirs = new Array<string>();
|
||||
async function createTemporaryDirectory(name: string): Promise<string> {
|
||||
|
||||
@@ -84,24 +84,24 @@ describe('resolvePackageName', () => {
|
||||
});
|
||||
|
||||
describe('populateOptions', () => {
|
||||
it('should return default values if not provided', async () => {
|
||||
expect(
|
||||
await populateOptions({}, { targetPath: '/example' } as Template),
|
||||
).toEqual({
|
||||
id: '',
|
||||
private: false,
|
||||
baseVersion: '0.0.0',
|
||||
owner: '',
|
||||
license: 'Apache-2.0',
|
||||
targetPath: '/example',
|
||||
scope: '',
|
||||
moduleId: '',
|
||||
});
|
||||
it('should return default values if not provided', () => {
|
||||
expect(populateOptions({}, { targetPath: '/example' } as Template)).toEqual(
|
||||
{
|
||||
id: '',
|
||||
private: false,
|
||||
baseVersion: '0.0.0',
|
||||
owner: '',
|
||||
license: 'Apache-2.0',
|
||||
targetPath: '/example',
|
||||
scope: '',
|
||||
moduleId: '',
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
it('should include all non-standard global and prompt values', async () => {
|
||||
it('should include all non-standard global and prompt values', () => {
|
||||
expect(
|
||||
await populateOptions({ foo: 'bar' }, {
|
||||
populateOptions({ foo: 'bar' }, {
|
||||
targetPath: '/example',
|
||||
} as Template),
|
||||
).toEqual({
|
||||
@@ -117,9 +117,9 @@ describe('populateOptions', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should priority global targetPath over the targetPath specified in template', async () => {
|
||||
it('should priority global targetPath over the targetPath specified in template', () => {
|
||||
expect(
|
||||
await populateOptions({ targetPath: '/global' }, {
|
||||
populateOptions({ targetPath: '/global' }, {
|
||||
targetPath: '/example',
|
||||
} as Template),
|
||||
).toEqual({
|
||||
|
||||
@@ -13,8 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import fs from 'fs-extra';
|
||||
import { paths } from '../paths';
|
||||
import { Template } from './types';
|
||||
|
||||
export interface Options extends Record<string, string | boolean> {
|
||||
@@ -52,28 +50,14 @@ export const resolvePackageName = (options: {
|
||||
return plugin ? `backstage-plugin-${baseName}` : baseName;
|
||||
};
|
||||
|
||||
async function calculateBaseVersion(baseVersion: string | undefined) {
|
||||
if (!baseVersion) {
|
||||
const lernaVersion = await fs
|
||||
.readJson(paths.resolveTargetRoot('lerna.json'))
|
||||
.then(pkg => pkg.version)
|
||||
.catch(() => undefined);
|
||||
if (lernaVersion) {
|
||||
return lernaVersion;
|
||||
}
|
||||
return '0.1.0';
|
||||
}
|
||||
return baseVersion;
|
||||
}
|
||||
|
||||
export async function populateOptions(
|
||||
export function populateOptions(
|
||||
prompts: Record<string, string>,
|
||||
template: Template,
|
||||
): Promise<Options> {
|
||||
): Options {
|
||||
return {
|
||||
id: prompts.id ?? '',
|
||||
private: !!prompts.private,
|
||||
baseVersion: await calculateBaseVersion(prompts.baseVersion),
|
||||
baseVersion: prompts.baseVersion ?? '0.1.0',
|
||||
owner: prompts.owner ?? '',
|
||||
license: prompts.license ?? 'Apache-2.0',
|
||||
targetPath: template.targetPath,
|
||||
|
||||
Reference in New Issue
Block a user