Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improvement(scope-fork), make the newScope argument optional. default to the defaultScope #8885

Merged
merged 2 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion scopes/component/forking/forking.main.runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,12 @@ export class ForkingMain {
*/
async forkScope(
originalScope: string,
newScope: string,
newOptionalScope?: string, // if not specified, it'll be the default scope
pattern?: string,
options?: ScopeForkOptions
): Promise<ComponentID[]> {
if (!this.workspace) throw new OutsideWorkspaceError();
const newScope = newOptionalScope || this.workspace.defaultScope;
const allIdsFromOriginalScope = await this.workspace.scope.listRemoteScope(originalScope);
if (!allIdsFromOriginalScope.length) {
throw new Error(`unable to find components to fork from ${originalScope}`);
Expand Down
6 changes: 3 additions & 3 deletions scopes/component/forking/scope-fork.cmd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ export type ScopeForkOptions = {
skipDependencyInstallation?: boolean;
};
export class ScopeForkCmd implements Command {
name = 'fork <original-scope> <new-scope> [pattern]';
name = 'fork <original-scope> [new-scope] [pattern]';
arguments = [
{
name: 'original-scope',
description: 'the original scope to fork',
},
{
name: 'new-scope',
description: 'the new scope to fork to',
description: 'the new scope to fork to, default to the default-scope of the workspace',
},
{
name: 'pattern',
Expand All @@ -37,7 +37,7 @@ export class ScopeForkCmd implements Command {
const forkedIds = await this.forking.forkScope(originalScope, newScope, pattern, options);
const title = chalk.green(
`successfully forked ${chalk.bold(originalScope)} into ${chalk.bold(
newScope
newScope || forkedIds[0].scope
)}. the following components were created`
);
return `${title}\n${forkedIds.map((id) => id.toString()).join('\n')}`;
Expand Down