<!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> <!-- If this is a particularly complex change or feature addition, you can request a dedicated Nx release for this pull request branch. Mention someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they will confirm if the PR warrants its own release for testing purposes, and generate it for you if appropriate. --> ## Current Behavior <!-- This is the behavior we have today --> The pattern added for .gitignore is incorrect ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> Add the correct pattern ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #28685
This commit is contained in:
parent
1e0423bcda
commit
9e598a6c1a
@ -7,7 +7,7 @@ exports[`app generated files content - as-provided - my-app general application
|
|||||||
.nuxt
|
.nuxt
|
||||||
.nitro
|
.nitro
|
||||||
.cache
|
.cache
|
||||||
**/vite.config.{js,ts,mjs,mts,cjs,cts}.timestamp*"
|
vite.config.*.timestamp*"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`app generated files content - as-provided - my-app general application should add the nuxt and vitest plugins 1`] = `
|
exports[`app generated files content - as-provided - my-app general application should add the nuxt and vitest plugins 1`] = `
|
||||||
@ -372,7 +372,7 @@ exports[`app generated files content - as-provided - myApp general application s
|
|||||||
.nuxt
|
.nuxt
|
||||||
.nitro
|
.nitro
|
||||||
.cache
|
.cache
|
||||||
**/vite.config.{js,ts,mjs,mts,cjs,cts}.timestamp*"
|
vite.config.*.timestamp*"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`app generated files content - as-provided - myApp general application should add the nuxt and vitest plugins 1`] = `
|
exports[`app generated files content - as-provided - myApp general application should add the nuxt and vitest plugins 1`] = `
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { stripIndents, Tree } from '@nx/devkit';
|
import { stripIndents, Tree } from '@nx/devkit';
|
||||||
|
|
||||||
export function addViteTempFilesToGitIgnore(tree: Tree) {
|
export function addViteTempFilesToGitIgnore(tree: Tree) {
|
||||||
let newGitIgnoreContents = `**/vite.config.{js,ts,mjs,mts,cjs,cts}.timestamp*`;
|
let newGitIgnoreContents = `vite.config.*.timestamp*`;
|
||||||
if (tree.exists('.gitignore')) {
|
if (tree.exists('.gitignore')) {
|
||||||
const gitIgnoreContents = tree.read('.gitignore', 'utf-8');
|
const gitIgnoreContents = tree.read('.gitignore', 'utf-8');
|
||||||
if (!gitIgnoreContents.includes(newGitIgnoreContents)) {
|
if (!gitIgnoreContents.includes(newGitIgnoreContents)) {
|
||||||
|
|||||||
@ -24,6 +24,11 @@
|
|||||||
"version": "20.0.4-beta.0",
|
"version": "20.0.4-beta.0",
|
||||||
"description": "Add gitignore entry for temporary vite config files.",
|
"description": "Add gitignore entry for temporary vite config files.",
|
||||||
"implementation": "./src/migrations/update-20-0-4/add-vite-temp-files-to-git-ignore"
|
"implementation": "./src/migrations/update-20-0-4/add-vite-temp-files-to-git-ignore"
|
||||||
|
},
|
||||||
|
"update-20-0-6": {
|
||||||
|
"version": "20.0.6-beta.0",
|
||||||
|
"description": "Add gitignore entry for temporary vite config files and remove previous incorrect glob.",
|
||||||
|
"implementation": "./src/migrations/update-20-0-4/add-vite-temp-files-to-git-ignore"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"packageJsonUpdates": {
|
"packageJsonUpdates": {
|
||||||
|
|||||||
@ -131,17 +131,14 @@ describe('@nx/vite:init', () => {
|
|||||||
|
|
||||||
it(`should not add multiple instances of the same vite temp file glob to gitignore`, async () => {
|
it(`should not add multiple instances of the same vite temp file glob to gitignore`, async () => {
|
||||||
// ARRANGE
|
// ARRANGE
|
||||||
tree.write(
|
tree.write('.gitignore', 'vite.config.*.timestamp*');
|
||||||
'.gitignore',
|
|
||||||
'**/vite.config.{js,ts,mjs,mts,cjs,cts}.timestamp*'
|
|
||||||
);
|
|
||||||
|
|
||||||
// ACT
|
// ACT
|
||||||
await initGenerator(tree, {});
|
await initGenerator(tree, {});
|
||||||
|
|
||||||
// ASSERT
|
// ASSERT
|
||||||
expect(tree.read('.gitignore', 'utf-8')).toMatchInlineSnapshot(
|
expect(tree.read('.gitignore', 'utf-8')).toMatchInlineSnapshot(
|
||||||
`"**/vite.config.{js,ts,mjs,mts,cjs,cts}.timestamp*"`
|
`"vite.config.*.timestamp*"`
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -13,7 +13,27 @@ describe('addViteTempFilesToGitIgnore', () => {
|
|||||||
// ASSERT
|
// ASSERT
|
||||||
expect(tree.read('.gitignore', 'utf-8')).toMatchInlineSnapshot(`
|
expect(tree.read('.gitignore', 'utf-8')).toMatchInlineSnapshot(`
|
||||||
".idea
|
".idea
|
||||||
**/vite.config.{js,ts,mjs,mts,cjs,cts}.timestamp*"
|
vite.config.*.timestamp*"
|
||||||
|
`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should update an existing .gitignore file and remove incorrect glob and add the glob correctly', () => {
|
||||||
|
// ARRANGE
|
||||||
|
const tree = createTreeWithEmptyWorkspace();
|
||||||
|
tree.write(
|
||||||
|
'.gitignore',
|
||||||
|
`.idea
|
||||||
|
**/vite.config.{js,ts,mjs,mts,cjs,cts}.timestamp*`
|
||||||
|
);
|
||||||
|
|
||||||
|
// ACT
|
||||||
|
addViteTempFilesToGitIgnore(tree);
|
||||||
|
|
||||||
|
// ASSERT
|
||||||
|
expect(tree.read('.gitignore', 'utf-8')).toMatchInlineSnapshot(`
|
||||||
|
".idea
|
||||||
|
|
||||||
|
vite.config.*.timestamp*"
|
||||||
`);
|
`);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -27,7 +47,7 @@ describe('addViteTempFilesToGitIgnore', () => {
|
|||||||
|
|
||||||
// ASSERT
|
// ASSERT
|
||||||
expect(tree.read('.gitignore', 'utf-8')).toMatchInlineSnapshot(
|
expect(tree.read('.gitignore', 'utf-8')).toMatchInlineSnapshot(
|
||||||
`"**/vite.config.{js,ts,mjs,mts,cjs,cts}.timestamp*"`
|
`"vite.config.*.timestamp*"`
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -2,5 +2,25 @@ import { Tree } from '@nx/devkit';
|
|||||||
import { addViteTempFilesToGitIgnore as _addViteTempFilesToGitIgnore } from '../../utils/add-vite-temp-files-to-gitignore';
|
import { addViteTempFilesToGitIgnore as _addViteTempFilesToGitIgnore } from '../../utils/add-vite-temp-files-to-gitignore';
|
||||||
|
|
||||||
export default function addViteTempFilesToGitIgnore(tree: Tree) {
|
export default function addViteTempFilesToGitIgnore(tree: Tree) {
|
||||||
|
// need to check if .gitignore exists before adding to it
|
||||||
|
// then need to check if it contains the following pattern
|
||||||
|
// **/vite.config.{js,ts,mjs,mts,cjs,cts}.timestamp*
|
||||||
|
// if it does, remove just this pattern
|
||||||
|
if (tree.exists('.gitignore')) {
|
||||||
|
const gitIgnoreContents = tree.read('.gitignore', 'utf-8');
|
||||||
|
if (
|
||||||
|
gitIgnoreContents.includes(
|
||||||
|
'**/vite.config.{js,ts,mjs,mts,cjs,cts}.timestamp*'
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
tree.write(
|
||||||
|
'.gitignore',
|
||||||
|
gitIgnoreContents.replace(
|
||||||
|
'**/vite.config.{js,ts,mjs,mts,cjs,cts}.timestamp*',
|
||||||
|
''
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
_addViteTempFilesToGitIgnore(tree);
|
_addViteTempFilesToGitIgnore(tree);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { stripIndents, Tree } from '@nx/devkit';
|
import { stripIndents, Tree } from '@nx/devkit';
|
||||||
|
|
||||||
export function addViteTempFilesToGitIgnore(tree: Tree) {
|
export function addViteTempFilesToGitIgnore(tree: Tree) {
|
||||||
let newGitIgnoreContents = `**/vite.config.{js,ts,mjs,mts,cjs,cts}.timestamp*`;
|
let newGitIgnoreContents = `vite.config.*.timestamp*`;
|
||||||
if (tree.exists('.gitignore')) {
|
if (tree.exists('.gitignore')) {
|
||||||
const gitIgnoreContents = tree.read('.gitignore', 'utf-8');
|
const gitIgnoreContents = tree.read('.gitignore', 'utf-8');
|
||||||
if (!gitIgnoreContents.includes(newGitIgnoreContents)) {
|
if (!gitIgnoreContents.includes(newGitIgnoreContents)) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user