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

Changed npmrc template name and updated gitignore content #91

Merged
merged 2 commits into from
Oct 6, 2023
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@adobe/aio-cli-plugin-api-mesh",
"version": "3.1.0-beta.1",
"version": "3.1.0-beta.2",
"publishConfig": {
"access": "public"
},
Expand Down
16 changes: 11 additions & 5 deletions src/commands/api-mesh/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,16 @@ class InitCommand extends Command {

async createDotNpmrcFile(templatePath, filePath) {
const dotNpmrcFile = await fs.readFile(templatePath, 'utf8');

await fs.writeFile(filePath, dotNpmrcFile, 'utf8', { mode: 'w' });
}

async createGitIgnoreFile(templatePath, filePath) {
const gitIgnoreFile = await fs.readFile(templatePath, 'utf8');

await fs.writeFile(filePath, gitIgnoreFile, 'utf8', { mode: 'w' });
}

async run() {
const { args, flags } = await this.parse(InitCommand);
const gitFlagOptions = {
Expand All @@ -86,7 +93,7 @@ class InitCommand extends Command {
let shouldCreateGit = gitFlagOptions[flags.git];
let packageManagerChoice = flags.packageManager;
const packageJsonTemplate = `${getAppRootDir()}/src/templates/package.json`;
const dotNpmrcPath = `${getAppRootDir()}/src/templates/.npmrc`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why change from .npmrc to npmrc?

Copy link
Contributor Author

@revanth0212 revanth0212 Oct 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While publishing . files are not published. For instance, here is the latest published package on npm, as you can see none of the . files are published

image

Similarly, template/.npmrc is also missing which wont let the init command to complete the setup

image

Hence changing it to npmrc instead. But while writing it into the user's inited folder, it will be named as .npmrc

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is from the npm docs, it says .npmrc along with a bunch of other files is always ignored https://docs.npmjs.com/cli/v9/configuring-npm/package-json#files

image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahh. This requires a .npmignore file and you can then specify the files you want in it like so
{
"files": ["index.js", "/lib"]
}
This whitelists everything inside and you can test it out by running npm pack

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But .npmrc is always ignored irrespective of files array or .npmignore

const dotNpmrcPath = `${getAppRootDir()}/src/templates/npmrc`;
const shouldCreateWorkspace = await promptConfirm(
`Do you want to create the workspace in ${absolutePath}`,
);
Expand Down Expand Up @@ -130,11 +137,10 @@ class InitCommand extends Command {
try {
await runCliCommand('git init', absolutePath);

const gitIgnoreTemplate = `${getAppRootDir()}/src/templates/gitignore`;
const gitIgnoreTemplatePath = `${getAppRootDir()}/src/templates/gitignore`;
const gitIgnoreFilePath = `${absolutePath}/.gitignore`;

await fs.writeFile(`${absolutePath}/.gitignore`, gitIgnoreTemplate, 'utf8', {
mode: 'w',
});
await this.createGitIgnoreFile(gitIgnoreTemplatePath, gitIgnoreFilePath);
} catch (error) {
this.error(error);
}
Expand Down
File renamed without changes.