Skip to content

Commit

Permalink
fix: update generate library command
Browse files Browse the repository at this point in the history
  • Loading branch information
iowillhoit committed Mar 13, 2024
1 parent cc8e175 commit fbefe01
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/commands/dev/generate/library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/


import { Messages } from '@salesforce/core';
import { SfCommand } from '@salesforce/sf-plugins-core';
import { generate } from '../../../util.js';

Messages.importMessagesDirectoryFromMetaUrl(import.meta.url)
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
const messages = Messages.loadMessages('@salesforce/plugin-dev', 'dev.generate.library');

export default class GenerateLibrary extends SfCommand<void> {
public static enableJsonFlag = false;
public static readonly hidden = true;
public static readonly summary = messages.getMessage('summary');
public static readonly description = messages.getMessage('description');
public static readonly examples = messages.getMessages('examples');
Expand Down
10 changes: 9 additions & 1 deletion src/generators/library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export default class Library extends Generator {
};

const directory = path.resolve(this.answers.name);
shelljs.exec(`git clone [email protected]:forcedotcom/library-template.git ${directory}`);
shelljs.exec(`git clone -b ew/update-template [email protected]:forcedotcom/library-template.git ${directory}`);
fs.rmSync(`${path.resolve(this.answers.name, '.git')}`, { recursive: true });
this.destinationRoot(directory);
this.env.cwd = this.destinationPath();
Expand All @@ -87,10 +87,18 @@ export default class Library extends Generator {
repository: `${this.answers.org}/${this.answers.name}`,
homepage: `https://github.com/${this.answers.org}/${this.answers.name}`,
description: this.answers.description,
bugs: { url: `https://github.com/${this.answers.org}/${this.answers.name}/issues` },
};
const final = Object.assign({}, pjson, updated);
this.fs.writeJSON(this.destinationPath('./package.json'), final);

// Replace the message import
replace.sync({
files: `${this.env.cwd}/src/hello.ts`,
from: /@salesforce\/library-template/g,
to: `${this.answers.scope}/${this.answers.name}`,
});

replace.sync({
files: `${this.env.cwd}/**/*`,
from: /library-template/g,
Expand Down

0 comments on commit fbefe01

Please sign in to comment.