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

Update generate library command #492

Merged
merged 2 commits into from
Mar 15, 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
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
8 changes: 8 additions & 0 deletions src/generators/library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading