-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
275 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
'@builder.io/qwik': minor | ||
--- | ||
|
||
FEAT: add monorepo support to the `qwik add` command by adding a `projectDir` param | ||
|
||
That way you can run `qwik add --projectDir=packages/my-package` and it will add the feature to the specified project/package (sub) folder, instead of the root folder. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import { fs } from 'memfs'; | ||
import { join } from 'path'; | ||
import { describe, expect, test, vi } from 'vitest'; | ||
import type { FsUpdates, UpdateAppOptions } from '../types'; | ||
import { mergeIntegrationDir } from './update-files'; | ||
|
||
vi.mock('node:fs', () => ({ | ||
default: fs, | ||
})); | ||
|
||
function setup() { | ||
const fakeSrcDir = 'srcDir'; | ||
createFakeFiles(fakeSrcDir); | ||
|
||
const fakeDestDir = 'destDir'; | ||
|
||
const fakeFileUpdates: FsUpdates = { | ||
files: [], | ||
installedDeps: {}, | ||
installedScripts: [], | ||
}; | ||
|
||
const fakeOpts: UpdateAppOptions = { | ||
rootDir: fakeDestDir, | ||
integration: 'integration', | ||
}; | ||
|
||
return { | ||
fakeSrcDir, | ||
fakeDestDir, | ||
fakeFileUpdates, | ||
fakeOpts, | ||
}; | ||
} | ||
|
||
describe('mergeIntegrationDir', () => { | ||
test('should merge integration directory', async () => { | ||
const { fakeSrcDir, fakeDestDir, fakeFileUpdates, fakeOpts } = setup(); | ||
|
||
await mergeIntegrationDir(fakeFileUpdates, fakeOpts, fakeSrcDir, fakeDestDir); | ||
|
||
const actualResults = fakeFileUpdates.files.map((f) => f.path); | ||
const expectedResult = ['destDir/fake.ts', 'destDir/package.json', 'destDir/src/global.css']; | ||
|
||
expect(actualResults).toEqual(expectedResult); | ||
}); | ||
|
||
test('should merge integration directory in a monorepo', async () => { | ||
const { fakeSrcDir, fakeDestDir, fakeFileUpdates, fakeOpts } = setup(); | ||
|
||
// Create a global file in the destination director | ||
const monorepoSubDir = join(fakeDestDir, 'apps', 'subpackage', 'src'); | ||
fs.mkdirSync(monorepoSubDir, { recursive: true }); | ||
fs.writeFileSync(join(monorepoSubDir, 'global.css'), '/* CSS */'); | ||
|
||
// Add a file that should stay in the root | ||
fs.writeFileSync(join(fakeSrcDir, 'should-stay-in-root.ts'), 'fake file'); | ||
|
||
// Creating a folder that should stay in the root | ||
fs.mkdirSync(join(fakeSrcDir, 'should-stay'), { recursive: true }); | ||
fs.writeFileSync(join(fakeSrcDir, 'should-stay', 'should-also-stay.ts'), 'fake file'); | ||
|
||
fakeOpts.projectDir = 'apps/subpackage'; | ||
fakeOpts.installDeps = true; | ||
const fakeAlwaysInRoot = ['should-stay-in-root.ts', 'should-stay']; | ||
|
||
await mergeIntegrationDir(fakeFileUpdates, fakeOpts, fakeSrcDir, fakeDestDir, fakeAlwaysInRoot); | ||
|
||
const actualResults = fakeFileUpdates.files.map((f) => f.path); | ||
const expectedResult = [ | ||
`destDir/apps/subpackage/fake.ts`, | ||
`destDir/should-stay-in-root.ts`, | ||
`destDir/package.json`, | ||
`destDir/should-stay/should-also-stay.ts`, | ||
`destDir/apps/subpackage/src/global.css`, | ||
]; | ||
|
||
expect(actualResults).toEqual(expectedResult); | ||
|
||
const actualGlobalCssContent = fakeFileUpdates.files.find( | ||
(f) => f.path === `destDir/apps/subpackage/src/global.css` | ||
)?.content; | ||
|
||
expect(actualGlobalCssContent).toBe('p{color: red}\n\n/* CSS */\n'); | ||
}); | ||
}); | ||
|
||
function createFakeFiles(dir: string) { | ||
// Create fake src files | ||
fs.mkdirSync(join(dir, 'src'), { recursive: true }); | ||
fs.writeFileSync(join(dir, 'fake.ts'), 'fake file'); | ||
fs.writeFileSync(join(dir, 'package.json'), '{"name": "fake"}'); | ||
fs.writeFileSync(join(dir, 'src', 'global.css'), 'p{color: red}'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.