-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
7c516e0
commit 8448ff8
Showing
153 changed files
with
1,446 additions
and
1,240 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
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
2 changes: 1 addition & 1 deletion
2
apps/app-builder/src/__tests__/createTestContextWithMockedFs.ts
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,8 @@ | ||
import {expect} from 'vitest'; | ||
import {fsModifyingMethods} from './spies/fs'; | ||
|
||
export const expectNoFileChanges = (): void => { | ||
fsModifyingMethods.forEach((spy) => { | ||
expect(spy).not.toHaveBeenCalled(); | ||
}); | ||
}; |
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
2 changes: 1 addition & 1 deletion
2
apps/app-builder/src/__tests__/mockFileSystemAndCreateContext.ts
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 was deleted.
Oops, something went wrong.
6 changes: 4 additions & 2 deletions
6
apps/app-builder/src/__tests__/setup.ts → ...uilder/src/__tests__/setup/globalSetup.ts
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 |
---|---|---|
@@ -1,14 +1,16 @@ | ||
import fs from 'fs'; | ||
import {MOCK_ROOT_DIR} from './constants'; | ||
import fs from 'node:fs'; | ||
import {MOCK_ROOT_DIR} from '../constants'; | ||
|
||
const restoreFileSystem = async () => { | ||
await fs.promises.rm(MOCK_ROOT_DIR, {recursive: true, force: true}); | ||
}; | ||
|
||
// noinspection JSUnusedGlobalSymbols | ||
export const teardown = async (): Promise<void> => { | ||
await restoreFileSystem(); | ||
}; | ||
|
||
// noinspection JSUnusedGlobalSymbols | ||
export const setup = async (): Promise<void> => { | ||
await restoreFileSystem(); | ||
}; |
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,17 @@ | ||
import fs from 'node:fs'; | ||
import {vi} from 'vitest'; | ||
|
||
vi.spyOn(fs, 'appendFile'); | ||
vi.spyOn(fs, 'copyFile'); | ||
vi.spyOn(fs, 'mkdir'); | ||
vi.spyOn(fs, 'rm'); | ||
vi.spyOn(fs, 'rmdir'); | ||
vi.spyOn(fs, 'unlink'); | ||
vi.spyOn(fs, 'writeFile'); | ||
vi.spyOn(fs.promises, 'appendFile'); | ||
vi.spyOn(fs.promises, 'copyFile'); | ||
vi.spyOn(fs.promises, 'mkdir'); | ||
vi.spyOn(fs.promises, 'rm'); | ||
vi.spyOn(fs.promises, 'rmdir'); | ||
vi.spyOn(fs.promises, 'unlink'); | ||
vi.spyOn(fs.promises, 'writeFile'); |
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 |
---|---|---|
@@ -1,36 +1,18 @@ | ||
// make a spy for all methods on fs.promises that modify the file system | ||
import fs from 'fs'; | ||
import {vi} from 'vitest'; | ||
import fs from 'node:fs'; | ||
|
||
const fsAppendFile = vi.spyOn(fs, 'appendFile'); | ||
const fsCopyFile = vi.spyOn(fs, 'copyFile'); | ||
const fsMkdir = vi.spyOn(fs, 'mkdir'); | ||
const fsRm = vi.spyOn(fs, 'rm'); | ||
const fsRmdir = vi.spyOn(fs, 'rmdir'); | ||
const fsUnlink = vi.spyOn(fs, 'unlink'); | ||
const fsWriteFile = vi.spyOn(fs, 'writeFile'); | ||
|
||
const fsPromisesAppendFile = vi.spyOn(fs.promises, 'appendFile'); | ||
const fsPromisesCopyFile = vi.spyOn(fs.promises, 'copyFile'); | ||
const fsPromisesMkdir = vi.spyOn(fs.promises, 'mkdir'); | ||
const fsPromisesRm = vi.spyOn(fs.promises, 'rm'); | ||
const fsPromisesRmdir = vi.spyOn(fs.promises, 'rmdir'); | ||
const fsPromisesUnlink = vi.spyOn(fs.promises, 'unlink'); | ||
const fsPromisesWriteFile = vi.spyOn(fs.promises, 'writeFile'); | ||
|
||
export const fsModifyingMethodSpies = [ | ||
fsAppendFile, | ||
fsCopyFile, | ||
fsMkdir, | ||
fsRm, | ||
fsRmdir, | ||
fsUnlink, | ||
fsWriteFile, | ||
fsPromisesAppendFile, | ||
fsPromisesCopyFile, | ||
fsPromisesMkdir, | ||
fsPromisesRm, | ||
fsPromisesRmdir, | ||
fsPromisesUnlink, | ||
fsPromisesWriteFile, | ||
export const fsModifyingMethods = [ | ||
fs.appendFile, | ||
fs.copyFile, | ||
fs.mkdir, | ||
fs.rm, | ||
fs.rmdir, | ||
fs.unlink, | ||
fs.writeFile, | ||
fs.promises.appendFile, | ||
fs.promises.copyFile, | ||
fs.promises.mkdir, | ||
fs.promises.rm, | ||
fs.promises.rmdir, | ||
fs.promises.unlink, | ||
fs.promises.writeFile, | ||
] as const; |
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 |
---|---|---|
@@ -1,8 +1,8 @@ | ||
import {rmDir} from '../utils/fs/rmDir'; | ||
import {type PdkBuilderCommand} from '../types/command'; | ||
import {deleteDirectory} from '../utils/fs/deleteDirectory'; | ||
import {type PdkBuilderCommand} from '../types/command.types'; | ||
|
||
const clean: PdkBuilderCommand = async (context) => { | ||
await rmDir(context.config.outDir, context); | ||
}; | ||
const clean = (async (context) => { | ||
await deleteDirectory(context, context.config.outDir); | ||
}) satisfies PdkBuilderCommand; | ||
|
||
export default clean; |
This file was deleted.
Oops, something went wrong.
19 changes: 9 additions & 10 deletions
19
apps/app-builder/src/commands/copy.spec.ts → ...pp-builder/src/commands/copy/copy.spec.ts
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,24 @@ | ||
import {resolvePath} from '../../utils/resolvePath'; | ||
import {copyFile} from '../../utils/fs/copyFile'; | ||
import {logTargetPath} from '../../utils/debug/logTargetPath'; | ||
import {type PdkBuilderContextWithPlatformArgs} from '../../types/command.types'; | ||
|
||
export const copyForPlatform = async ( | ||
context: PdkBuilderContextWithPlatformArgs, | ||
sourceFiles: string[], | ||
): Promise<void> => { | ||
const {args, debug} = context; | ||
|
||
debug('Copying files to %s', logTargetPath(args.platformOutDir, context)); | ||
|
||
await Promise.all( | ||
sourceFiles.map(async (file) => { | ||
const source = resolvePath(file, context); | ||
const target = resolvePath([args.platformOutDir, file], context); | ||
|
||
await copyFile(source, target, context); | ||
}), | ||
); | ||
|
||
debug('Finished copying files to %s', logTargetPath(args.platformOutDir, context)); | ||
}; |
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,24 @@ | ||
import {usesPhpScoper} from '../../utils/usesPhpScoper'; | ||
import {globFiles} from '../../utils/globFiles'; | ||
import {copyScopedFilesForPlatform} from '../../utils/copyScopedFilesForPlatform'; | ||
import {executePerPlatform} from '../../utils/command/executePerPlatform'; | ||
import {type PdkBuilderCommand} from '../../types/command.types'; | ||
import {copyForPlatform} from './copyForPlatform'; | ||
|
||
const copy = (async (context) => { | ||
const {debug, config} = context; | ||
|
||
const files = globFiles(config.source, context).sort(); | ||
|
||
await executePerPlatform(context, (context) => copyForPlatform(context, files)); | ||
|
||
debug('Finished copying files'); | ||
|
||
if (await usesPhpScoper(context)) { | ||
await executePerPlatform(context, copyScopedFilesForPlatform); | ||
|
||
debug('Finished copying scoped files'); | ||
} | ||
}) satisfies PdkBuilderCommand; | ||
|
||
export default copy; |
Oops, something went wrong.