@stripchatdev/create-stripchat-extension 0.1.45 → 0.1.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/cli/actions/updateAction.d.ts +6 -0
- package/dist/bin/cli/actions/updateAction.js +33 -0
- package/dist/bin/cli/helpers/printCliError.d.ts +1 -0
- package/dist/bin/cli/helpers/printCliError.js +21 -0
- package/dist/bin/cli/index.js +70 -0
- package/dist/bin/create.d.ts +2 -0
- package/dist/bin/create.js +238 -0
- package/dist/package.json +5 -2
- package/dist/src/constants.d.ts +14 -9
- package/dist/src/constants.js +53 -8
- package/dist/src/dependencies/constants.d.ts +2 -0
- package/dist/src/dependencies/constants.js +11 -0
- package/dist/src/dependencies/resolveDependencies.d.ts +6 -0
- package/dist/src/dependencies/resolveDependencies.js +43 -0
- package/dist/src/dependencies/resolveDependencies.test.js +74 -0
- package/dist/src/helpers/error.d.ts +3 -0
- package/dist/src/helpers/error.js +9 -0
- package/dist/src/helpers/error.test.js +15 -0
- package/dist/src/helpers/getIsDirectoryExists.d.ts +7 -0
- package/dist/src/helpers/getIsDirectoryExists.js +23 -0
- package/dist/src/helpers/getIsDirectoryExists.test.js +34 -0
- package/dist/src/helpers/getIsJsxFramework.d.ts +2 -0
- package/dist/src/helpers/getIsJsxFramework.js +2 -0
- package/dist/src/helpers/getIsJsxFramework.test.js +10 -0
- package/dist/src/helpers/getIsTypescript.d.ts +2 -0
- package/dist/src/helpers/getIsTypescript.js +1 -0
- package/dist/src/helpers/getIsTypescript.test.js +10 -0
- package/dist/src/helpers/isSubPath.d.ts +1 -0
- package/dist/src/helpers/isSubPath.js +5 -0
- package/dist/src/helpers/normalizePath.d.ts +2 -0
- package/dist/src/helpers/normalizePath.js +4 -0
- package/dist/src/helpers/normalizePath.test.js +19 -0
- package/dist/src/migrator/executor.d.ts +9 -0
- package/dist/src/migrator/executor.js +112 -0
- package/dist/src/migrator/migration.d.ts +3 -0
- package/dist/src/migrator/migration.js +18 -0
- package/dist/src/migrator/migration.test.js +74 -0
- package/dist/src/migrator/migrations/migrations.test.js +97 -0
- package/dist/src/migrator/migrations/v2/AGENTS_md/001_recreate-with-generated-part.d.ts +2 -0
- package/dist/src/migrator/migrations/v2/AGENTS_md/001_recreate-with-generated-part.js +14 -0
- package/dist/src/migrator/migrations/v2/_project-config_json/001_create.d.ts +2 -0
- package/dist/src/migrator/migrations/v2/_project-config_json/001_create.js +14 -0
- package/dist/src/migrator/migrations/v2/vite_config_ts/001_turn_off_minify_and_assets_inline.d.ts +2 -0
- package/dist/src/migrator/migrations/v2/vite_config_ts/001_turn_off_minify_and_assets_inline.js +118 -0
- package/dist/src/migrator/planner.d.ts +5 -0
- package/dist/src/migrator/planner.js +65 -0
- package/dist/src/migrator/planner.test.js +40 -0
- package/dist/src/migrator/types.d.ts +29 -0
- package/dist/src/migrator/updates/updates.test.js +102 -0
- package/dist/src/migrator/updates/v2/AGENTS_md/001_update-generated-part.d.ts +2 -0
- package/dist/src/migrator/updates/v2/AGENTS_md/001_update-generated-part.js +38 -0
- package/dist/src/migrator/updates/v2/package_json/001_update-versions.d.ts +2 -0
- package/dist/src/migrator/updates/v2/package_json/001_update-versions.js +77 -0
- package/dist/src/migrator/updates/v2/package_json/002_add-cli-commands.d.ts +2 -0
- package/dist/src/migrator/updates/v2/package_json/002_add-cli-commands.js +61 -0
- package/dist/src/migrator/validators/getIsValidMigration.d.ts +2 -0
- package/dist/src/migrator/validators/getIsValidMigration.js +3 -0
- package/dist/src/migrator/validators/getIsValidMigration.test.js +13 -0
- package/dist/src/projectConfig/buildProjectConfig.d.ts +15 -0
- package/dist/src/projectConfig/buildProjectConfig.js +27 -0
- package/dist/src/projectConfig/detectPackageManagerRuntime.d.ts +2 -0
- package/dist/src/{helpers/detectPackageManager.js → projectConfig/detectPackageManagerRuntime.js} +1 -1
- package/dist/src/{helpers/detectPackageManager.test.js → projectConfig/detectPackageManagerRuntime.test.js} +10 -10
- package/dist/src/projectConfig/recoverProjectConfig.d.ts +1 -0
- package/dist/src/projectConfig/recoverProjectConfig.js +34 -0
- package/dist/src/projectConfig/recovery/detectPackageManagerFromFiles.d.ts +2 -0
- package/dist/src/projectConfig/recovery/detectPackageManagerFromFiles.js +16 -0
- package/dist/src/projectConfig/recovery/detectPackageManagerFromFiles.test.d.ts +1 -0
- package/dist/src/projectConfig/recovery/detectPackageManagerFromFiles.test.js +37 -0
- package/dist/src/projectConfig/recovery/parseAgentsMd.d.ts +10 -0
- package/dist/src/projectConfig/recovery/parseAgentsMd.js +52 -0
- package/dist/src/projectConfig/recovery/parseAgentsMd.test.d.ts +1 -0
- package/dist/src/projectConfig/recovery/parseAgentsMd.test.js +67 -0
- package/dist/src/projectConfig/recovery/resolveProjectNameFromDir.d.ts +1 -0
- package/dist/src/projectConfig/recovery/resolveProjectNameFromDir.js +11 -0
- package/dist/src/projectConfig/recovery/resolveProjectNameFromDir.test.d.ts +1 -0
- package/dist/src/projectConfig/recovery/resolveProjectNameFromDir.test.js +21 -0
- package/dist/src/projectConfig/resolveExistsProjectConfig.d.ts +2 -0
- package/dist/src/projectConfig/resolveExistsProjectConfig.js +34 -0
- package/dist/src/projectConfig/updateProjectConfig.d.ts +2 -0
- package/dist/src/projectConfig/updateProjectConfig.js +20 -0
- package/dist/src/projectConfig/validators/getIsValidProjectConfig.d.ts +2 -0
- package/dist/src/projectConfig/validators/getIsValidProjectConfig.js +6 -0
- package/dist/src/projectConfig/validators/getIsValidProjectConfig.test.d.ts +1 -0
- package/dist/src/projectConfig/validators/getIsValidProjectConfig.test.js +33 -0
- package/dist/src/projectConfig/validators/validateProjectConfig.d.ts +2 -0
- package/dist/src/projectConfig/validators/validateProjectConfig.js +30 -0
- package/dist/src/projectConfig/validators/validateProjectConfig.test.d.ts +1 -0
- package/dist/src/projectConfig/validators/validateProjectConfig.test.js +215 -0
- package/dist/src/templater/executor.d.ts +2 -0
- package/dist/src/templater/executor.js +22 -0
- package/dist/src/templater/executor.test.d.ts +1 -0
- package/dist/src/{executor.test.js → templater/executor.test.js} +25 -11
- package/dist/src/templater/helpers/getIsTypescriptOnlyFile.d.ts +1 -0
- package/dist/src/templater/helpers/getIsTypescriptOnlyFile.js +10 -0
- package/dist/src/templater/helpers/getIsTypescriptOnlyFile.test.d.ts +1 -0
- package/dist/src/templater/helpers/getIsTypescriptOnlyFile.test.js +25 -0
- package/dist/src/templater/helpers/resolveTemplateExtension.d.ts +1 -0
- package/dist/src/templater/helpers/resolveTemplateExtension.js +16 -0
- package/dist/src/templater/helpers/resolveTemplateExtension.test.d.ts +1 -0
- package/dist/src/{mappers → templater/mappers}/mapProjectConfigToTemplateModel.d.ts +1 -1
- package/dist/src/{mappers → templater/mappers}/mapProjectConfigToTemplateModel.js +6 -8
- package/dist/src/templater/mappers/mapProjectConfigToTemplateModel.test.d.ts +1 -0
- package/dist/src/{mappers → templater/mappers}/mapProjectConfigToTemplateModel.test.js +29 -23
- package/dist/src/templater/planner.d.ts +2 -0
- package/dist/src/templater/planner.js +104 -0
- package/dist/src/templater/planner.test.d.ts +1 -0
- package/dist/src/templater/planner.test.js +64 -0
- package/dist/src/templates/constants.d.ts +6 -0
- package/dist/src/templates/constants.js +11 -0
- package/dist/src/templates/helpers/resolveTemplatesDir.d.ts +1 -0
- package/dist/src/templates/helpers/resolveTemplatesDir.js +16 -0
- package/dist/src/templates/templates.d.ts +10 -0
- package/dist/src/templates/templates.js +133 -0
- package/dist/src/templates/templates.test.d.ts +1 -0
- package/dist/src/templates/templates.test.js +263 -0
- package/dist/src/templates/types.d.ts +21 -0
- package/dist/src/templates/types.js +1 -0
- package/dist/src/types.d.ts +28 -9
- package/dist/src/validators/getIsValidCategory.d.ts +2 -0
- package/dist/src/validators/getIsValidCategory.js +2 -0
- package/dist/src/validators/getIsValidCategory.test.d.ts +1 -0
- package/dist/src/validators/{isValidCategory.test.js → getIsValidCategory.test.js} +3 -3
- package/dist/src/validators/getIsValidFramework.d.ts +2 -0
- package/dist/src/validators/getIsValidFramework.js +2 -0
- package/dist/src/validators/getIsValidFramework.test.d.ts +1 -0
- package/dist/src/validators/{isValidFramework.test.js → getIsValidFramework.test.js} +3 -3
- package/dist/src/validators/getIsValidLanguage.d.ts +2 -0
- package/dist/src/validators/getIsValidLanguage.js +2 -0
- package/dist/src/validators/getIsValidLanguage.test.d.ts +1 -0
- package/dist/src/validators/{isValidLanguage.test.js → getIsValidLanguage.test.js} +3 -3
- package/dist/src/validators/getIsValidPackageManager.d.ts +2 -0
- package/dist/src/validators/getIsValidPackageManager.js +4 -0
- package/dist/src/validators/getIsValidPackageManager.test.d.ts +1 -0
- package/dist/src/validators/getIsValidPackageManager.test.js +11 -0
- package/dist/src/validators/getIsValidSlot.d.ts +2 -0
- package/dist/src/validators/getIsValidSlot.js +4 -0
- package/dist/src/validators/getIsValidSlot.test.d.ts +1 -0
- package/dist/src/validators/getIsValidSlot.test.js +26 -0
- package/dist/src/validators/validateSlots.js +40 -8
- package/dist/src/validators/validateSlots.test.js +125 -34
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -2
- package/templates/v1/vite.config.ts.ejs +27 -0
- package/templates/v2/.project-config.json.ejs +1 -0
- package/templates/v2/AGENTS.md.ejs +712 -0
- package/templates/v2/README.md.ejs +31 -0
- package/templates/v2/package.json.ejs +26 -0
- package/dist/bin/cli.js +0 -221
- package/dist/src/executor.d.ts +0 -2
- package/dist/src/executor.js +0 -22
- package/dist/src/helpers/detectPackageManager.d.ts +0 -2
- package/dist/src/helpers/isDirectory.d.ts +0 -1
- package/dist/src/helpers/isDirectory.js +0 -9
- package/dist/src/helpers/isDirectory.test.js +0 -22
- package/dist/src/helpers/isTypescriptOnlyFile.d.ts +0 -1
- package/dist/src/helpers/isTypescriptOnlyFile.js +0 -5
- package/dist/src/helpers/isTypescriptOnlyFile.test.js +0 -22
- package/dist/src/helpers/normalizeRelPath.d.ts +0 -1
- package/dist/src/helpers/normalizeRelPath.js +0 -1
- package/dist/src/helpers/normalizeRelPath.test.js +0 -19
- package/dist/src/helpers/resolveTemplateExtension.d.ts +0 -1
- package/dist/src/helpers/resolveTemplateExtension.js +0 -17
- package/dist/src/helpers/resolveTemplatesDir.d.ts +0 -1
- package/dist/src/helpers/resolveTemplatesDir.js +0 -11
- package/dist/src/helpers/resolveTemplatesDir.test.js +0 -21
- package/dist/src/planner.d.ts +0 -2
- package/dist/src/planner.js +0 -126
- package/dist/src/planner.test.js +0 -58
- package/dist/src/validators/index.d.ts +0 -6
- package/dist/src/validators/index.js +0 -6
- package/dist/src/validators/isValidCategory.d.ts +0 -2
- package/dist/src/validators/isValidCategory.js +0 -2
- package/dist/src/validators/isValidFramework.d.ts +0 -2
- package/dist/src/validators/isValidFramework.js +0 -2
- package/dist/src/validators/isValidLanguage.d.ts +0 -2
- package/dist/src/validators/isValidLanguage.js +0 -2
- package/dist/src/validators/validateProjectDir.d.ts +0 -1
- package/dist/src/validators/validateProjectDir.js +0 -6
- package/dist/src/validators/validateProjectDir.test.js +0 -19
- package/dist/bin/{cli.d.ts → cli/index.d.ts} +0 -0
- package/dist/src/{executor.test.d.ts → dependencies/resolveDependencies.test.d.ts} +0 -0
- package/dist/src/helpers/{detectPackageManager.test.d.ts → error.test.d.ts} +0 -0
- package/dist/src/helpers/{isDirectory.test.d.ts → getIsDirectoryExists.test.d.ts} +0 -0
- package/dist/src/helpers/{isTypescriptOnlyFile.test.d.ts → getIsJsxFramework.test.d.ts} +0 -0
- package/dist/src/helpers/{normalizeRelPath.test.d.ts → getIsTypescript.test.d.ts} +0 -0
- package/dist/src/helpers/{resolveTemplateExtension.test.d.ts → normalizePath.test.d.ts} +0 -0
- package/dist/src/{helpers/resolveTemplatesDir.test.d.ts → migrator/migration.test.d.ts} +0 -0
- package/dist/src/{mappers/mapProjectConfigToTemplateModel.test.d.ts → migrator/migrations/migrations.test.d.ts} +0 -0
- package/dist/src/{planner.test.d.ts → migrator/planner.test.d.ts} +0 -0
- package/dist/src/{validators/isValidCategory.test.d.ts → migrator/types.js} +0 -0
- package/dist/src/{validators/isValidFramework.test.d.ts → migrator/updates/updates.test.d.ts} +0 -0
- package/dist/src/{validators/isValidLanguage.test.d.ts → migrator/validators/getIsValidMigration.test.d.ts} +0 -0
- package/dist/src/{validators/validateProjectDir.test.d.ts → projectConfig/detectPackageManagerRuntime.test.d.ts} +0 -0
- package/dist/src/{helpers → templater/helpers}/resolveTemplateExtension.test.js +0 -0
- package/templates/{.gitignore.ejs → v1/.gitignore.ejs} +0 -0
- package/templates/{AGENTS.md.ejs → v1/AGENTS.md.ejs} +0 -0
- package/templates/{CLAUDE.md → v1/CLAUDE.md} +0 -0
- package/templates/{README.md.ejs → v1/README.md.ejs} +0 -0
- package/templates/{package.json.ejs → v1/package.json.ejs} +0 -0
- package/templates/{public → v1/public}/icon.svg +0 -0
- package/templates/{public → v1/public}/manifest.json.ejs +0 -0
- package/templates/{public → v1/public}/resolveSlotPage.js.ejs +0 -0
- package/templates/{src → v1/src}/slots/background/app.ts.ejs +0 -0
- package/templates/{src → v1/src}/slots/background/background.html.ejs +0 -0
- package/templates/{src → v1/src}/slots/background/main.ts.ejs +0 -0
- package/templates/{src/slots/slot/slot.html.ejs → v1/src/slots/slot/__SLOT_KEY__.html.ejs} +0 -0
- package/templates/{src → v1/src}/slots/slot/app.ts.ejs +0 -0
- package/templates/{src → v1/src}/slots/slot/app.tsx.ejs +0 -0
- package/templates/{src → v1/src}/slots/slot/main.css.ejs +0 -0
- package/templates/{src → v1/src}/slots/slot/main.ts.ejs +0 -0
- package/templates/{src → v1/src}/slots/slot/main.tsx.ejs +0 -0
- package/templates/{tsconfig.json.ejs → v1/tsconfig.json.ejs} +0 -0
- package/templates/{vite.config.ts.ejs → v2/vite.config.ts.ejs} +1 -1
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { tmpdir } from 'node:os';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { describe, it, expect } from 'vitest';
|
|
5
|
+
import { PACKAGE_MANAGER_LOCK_FILE_MAP } from '../../constants.js';
|
|
6
|
+
import { detectPackageManagerFromFiles } from './detectPackageManagerFromFiles.js';
|
|
7
|
+
const createDirWithLockfile = (packageLockRelPath) => {
|
|
8
|
+
const projectDir = mkdtempSync(join(tmpdir(), 'sce-detectPackageManagerFromFiles-'));
|
|
9
|
+
writeFileSync(join(projectDir, packageLockRelPath), '', {
|
|
10
|
+
encoding: 'utf8',
|
|
11
|
+
});
|
|
12
|
+
return projectDir;
|
|
13
|
+
};
|
|
14
|
+
describe('detectPackageManagerFromFiles', () => {
|
|
15
|
+
it('return value from valid lock', () => {
|
|
16
|
+
const packageManager = 'npm';
|
|
17
|
+
const packageLockFileName = PACKAGE_MANAGER_LOCK_FILE_MAP[packageManager];
|
|
18
|
+
const projectDir = createDirWithLockfile(packageLockFileName);
|
|
19
|
+
try {
|
|
20
|
+
const result = detectPackageManagerFromFiles(projectDir);
|
|
21
|
+
expect(result).toBe(packageManager);
|
|
22
|
+
}
|
|
23
|
+
finally {
|
|
24
|
+
rmSync(projectDir, { recursive: true, force: true });
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
it('return null is no known lock file', () => {
|
|
28
|
+
const projectDir = createDirWithLockfile('some.lock');
|
|
29
|
+
try {
|
|
30
|
+
const result = detectPackageManagerFromFiles(projectDir);
|
|
31
|
+
expect(result).toBe(null);
|
|
32
|
+
}
|
|
33
|
+
finally {
|
|
34
|
+
rmSync(projectDir, { recursive: true, force: true });
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { TCategory, TFramework, TLanguage, TSlot } from '../../types.js';
|
|
2
|
+
type TParseAgentsMdResult = {
|
|
3
|
+
category?: TCategory;
|
|
4
|
+
framework?: TFramework;
|
|
5
|
+
language?: TLanguage;
|
|
6
|
+
slots: TSlot[];
|
|
7
|
+
};
|
|
8
|
+
export declare const parseAgentsMdV1: (projectDir: string) => TParseAgentsMdResult;
|
|
9
|
+
export declare const parseAgentsMd: (projectDir: string, templateVersion: number) => TParseAgentsMdResult;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { AGENTS_MD_REL_PATH } from '../../constants.js';
|
|
4
|
+
import { AppError } from '../../helpers/error.js';
|
|
5
|
+
import { getIsValidCategory } from '../../validators/getIsValidCategory.js';
|
|
6
|
+
import { getIsValidFramework } from '../../validators/getIsValidFramework.js';
|
|
7
|
+
import { getIsValidLanguage } from '../../validators/getIsValidLanguage.js';
|
|
8
|
+
import { getIsValidSlot } from '../../validators/getIsValidSlot.js';
|
|
9
|
+
export const parseAgentsMdV1 = (projectDir) => {
|
|
10
|
+
const result = {
|
|
11
|
+
slots: [],
|
|
12
|
+
};
|
|
13
|
+
const agentsMdPath = join(projectDir, AGENTS_MD_REL_PATH);
|
|
14
|
+
if (!existsSync(agentsMdPath)) {
|
|
15
|
+
throw new AppError(`Agents.md not found, can not recover project config: ${agentsMdPath}`);
|
|
16
|
+
}
|
|
17
|
+
const content = readFileSync(agentsMdPath, 'utf8');
|
|
18
|
+
const languageMatch = content.match(/-\sLanguage: (.+)/);
|
|
19
|
+
const frameworkMatch = content.match(/-\sFramework: (.+)/);
|
|
20
|
+
const categoryMatch = content.match(/-\sCategory: (.+)/);
|
|
21
|
+
const slotsMatch = content.match(/-\sSlots: (.+)/);
|
|
22
|
+
const languageRaw = languageMatch?.[1] || '';
|
|
23
|
+
const frameworkRaw = frameworkMatch?.[1] || '';
|
|
24
|
+
const categoryRaw = categoryMatch?.[1] || '';
|
|
25
|
+
const slotsRaw = slotsMatch?.[1] || '';
|
|
26
|
+
if (getIsValidLanguage(languageRaw)) {
|
|
27
|
+
result.language = languageRaw;
|
|
28
|
+
}
|
|
29
|
+
if (getIsValidFramework(frameworkRaw)) {
|
|
30
|
+
result.framework = frameworkRaw;
|
|
31
|
+
}
|
|
32
|
+
if (getIsValidCategory(categoryRaw)) {
|
|
33
|
+
result.category = categoryRaw;
|
|
34
|
+
}
|
|
35
|
+
const slots = new Set();
|
|
36
|
+
const slotsRawParts = slotsRaw.split(', ');
|
|
37
|
+
slotsRawParts.forEach((slot) => {
|
|
38
|
+
if (getIsValidSlot(slot)) {
|
|
39
|
+
slots.add(slot);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
result.slots = Array.from(slots);
|
|
43
|
+
return result;
|
|
44
|
+
};
|
|
45
|
+
export const parseAgentsMd = (projectDir, templateVersion) => {
|
|
46
|
+
switch (templateVersion) {
|
|
47
|
+
case 1:
|
|
48
|
+
return parseAgentsMdV1(projectDir);
|
|
49
|
+
default:
|
|
50
|
+
throw new AppError('Failed to parse agents md file, version is not supported');
|
|
51
|
+
}
|
|
52
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { tmpdir } from 'node:os';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { describe, it, expect } from 'vitest';
|
|
5
|
+
import { CLI_COMMANDS_MAP, EXT_HELPER_VERSION } from '../../constants.js';
|
|
6
|
+
import { executeCommands } from '../../templater/executor.js';
|
|
7
|
+
import { mapProjectConfigToTemplateData } from '../../templater/mappers/mapProjectConfigToTemplateModel.js';
|
|
8
|
+
import { planProject } from '../../templater/planner.js';
|
|
9
|
+
import { MANAGED_TEMPLATES } from '../../templates/constants.js';
|
|
10
|
+
import { LAST_TEMPLATE_VERSION, TEMPLATES_DIR } from '../../templates/templates.js';
|
|
11
|
+
import { buildProjectConfig } from '../buildProjectConfig.js';
|
|
12
|
+
import { parseAgentsMd } from './parseAgentsMd.js';
|
|
13
|
+
const testProjectConfig = buildProjectConfig({
|
|
14
|
+
category: 'games-and-fun',
|
|
15
|
+
framework: 'preact',
|
|
16
|
+
lastTemplateVersion: LAST_TEMPLATE_VERSION,
|
|
17
|
+
cliCommands: CLI_COMMANDS_MAP,
|
|
18
|
+
managedTemplates: MANAGED_TEMPLATES,
|
|
19
|
+
templatesDir: TEMPLATES_DIR,
|
|
20
|
+
name: 'test',
|
|
21
|
+
slots: ['EXTENSION_SLOT_MAIN_GAME_FUN', 'EXTENSION_SLOT_BACKGROUND'],
|
|
22
|
+
extHelperVersion: EXT_HELPER_VERSION,
|
|
23
|
+
language: 'ts',
|
|
24
|
+
packageManager: 'npm',
|
|
25
|
+
});
|
|
26
|
+
describe('parseAgentsMd', () => {
|
|
27
|
+
it('throw error if agents md is not 1 version', () => {
|
|
28
|
+
expect(() => parseAgentsMd('/some-project-dir', 2)).toThrow();
|
|
29
|
+
});
|
|
30
|
+
it('throw error in agents md is not found', () => {
|
|
31
|
+
expect(() => parseAgentsMd('/some-project-dir', 1)).toThrow();
|
|
32
|
+
});
|
|
33
|
+
it('correct parse all data', () => {
|
|
34
|
+
const projectDir = mkdtempSync(join(tmpdir(), 'sce-parse-agents-md-'));
|
|
35
|
+
try {
|
|
36
|
+
const templateVersion = 1;
|
|
37
|
+
const templateData = mapProjectConfigToTemplateData(testProjectConfig);
|
|
38
|
+
const commands = planProject(projectDir, templateVersion, templateData);
|
|
39
|
+
executeCommands(commands);
|
|
40
|
+
const result = parseAgentsMd(projectDir, templateVersion);
|
|
41
|
+
expect(result).toEqual({
|
|
42
|
+
category: templateData.config.category,
|
|
43
|
+
framework: templateData.config.framework,
|
|
44
|
+
language: templateData.config.language,
|
|
45
|
+
slots: templateData.config.slots,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
finally {
|
|
49
|
+
rmSync(projectDir, { force: true, recursive: true });
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
it('return empty values for non parsed values', () => {
|
|
53
|
+
const projectDir = mkdtempSync(join(tmpdir(), 'sce-parse-agents-md-'));
|
|
54
|
+
try {
|
|
55
|
+
writeFileSync(join(projectDir, 'AGENTS.md'), 'some invalid content', {
|
|
56
|
+
encoding: 'utf8',
|
|
57
|
+
});
|
|
58
|
+
const result = parseAgentsMd(projectDir, 1);
|
|
59
|
+
expect(result).toEqual({
|
|
60
|
+
slots: [],
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
finally {
|
|
64
|
+
rmSync(projectDir, { force: true, recursive: true });
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const resolveProjectNameFromDir: (projectDir: string) => string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { basename } from 'node:path';
|
|
2
|
+
import { AppError } from '../../helpers/error.js';
|
|
3
|
+
import { validateName } from '../../validators/validateName.js';
|
|
4
|
+
export const resolveProjectNameFromDir = (projectDir) => {
|
|
5
|
+
const name = basename(projectDir);
|
|
6
|
+
const result = validateName(name);
|
|
7
|
+
if (result === true) {
|
|
8
|
+
return name;
|
|
9
|
+
}
|
|
10
|
+
throw new AppError(`Unable to resolve valid project name: ${result}`);
|
|
11
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { AppError } from '../../helpers/error.js';
|
|
3
|
+
import { resolveProjectNameFromDir } from './resolveProjectNameFromDir.js';
|
|
4
|
+
describe('resolveProjectNameFromDir', () => {
|
|
5
|
+
it('returns valid project name from directory basename', () => {
|
|
6
|
+
expect(resolveProjectNameFromDir('/tmp/some-extension')).toBe('some-extension');
|
|
7
|
+
});
|
|
8
|
+
it('returns valid project name from directory basename with trailing slash', () => {
|
|
9
|
+
expect(resolveProjectNameFromDir('/tmp/some-extension/')).toBe('some-extension');
|
|
10
|
+
});
|
|
11
|
+
it('throws AppError when basename is not a valid project name', () => {
|
|
12
|
+
try {
|
|
13
|
+
resolveProjectNameFromDir('/tmp/Invalid Name With Spaces');
|
|
14
|
+
throw new Error('Expected resolveProjectNameFromDir to throw');
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
expect(error).toBeInstanceOf(AppError);
|
|
18
|
+
expect(error.message).toMatch(/^Unable to resolve valid project name:/);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { PROJECT_CONFIG_REL_PATH } from '../constants.js';
|
|
4
|
+
import { AppError } from '../helpers/error.js';
|
|
5
|
+
import { recoverProjectConfig } from './recoverProjectConfig.js';
|
|
6
|
+
import { getIsValidProjectConfig } from './validators/getIsValidProjectConfig.js';
|
|
7
|
+
import { validateProjectConfig } from './validators/validateProjectConfig.js';
|
|
8
|
+
export const resolveExistsProjectConfig = (projectDir) => {
|
|
9
|
+
const projectConfigPath = join(projectDir, PROJECT_CONFIG_REL_PATH);
|
|
10
|
+
let projectConfig;
|
|
11
|
+
if (!existsSync(projectConfigPath)) {
|
|
12
|
+
projectConfig = recoverProjectConfig(projectDir);
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
const contentRaw = readFileSync(projectConfigPath, 'utf8');
|
|
16
|
+
if (!contentRaw) {
|
|
17
|
+
throw new AppError(`Project config is empty: ${projectConfigPath}`);
|
|
18
|
+
}
|
|
19
|
+
try {
|
|
20
|
+
projectConfig = JSON.parse(contentRaw);
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
throw new AppError(`Failed to parse exists project config: ${projectConfigPath}`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (!getIsValidProjectConfig(projectConfig)) {
|
|
27
|
+
throw new AppError(`Project config is invalid: ${projectConfigPath}`);
|
|
28
|
+
}
|
|
29
|
+
const validationResult = validateProjectConfig(projectConfig);
|
|
30
|
+
if (validationResult !== true) {
|
|
31
|
+
throw new AppError(`Project config setup is invalid: ${validationResult}`);
|
|
32
|
+
}
|
|
33
|
+
return projectConfig;
|
|
34
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { CLI_COMMANDS_MAP, EXT_HELPER_VERSION } from '../constants.js';
|
|
2
|
+
import { MANAGED_TEMPLATES } from '../templates/constants.js';
|
|
3
|
+
import { TEMPLATES_DIR } from '../templates/templates.js';
|
|
4
|
+
import { buildProjectConfig } from './buildProjectConfig.js';
|
|
5
|
+
export const updateProjectConfig = (lastTemplateVersion, projectConfigUserProps) => {
|
|
6
|
+
const { category, framework, language, name, packageManager, slots } = projectConfigUserProps;
|
|
7
|
+
return buildProjectConfig({
|
|
8
|
+
name,
|
|
9
|
+
category,
|
|
10
|
+
language,
|
|
11
|
+
framework,
|
|
12
|
+
packageManager,
|
|
13
|
+
slots,
|
|
14
|
+
extHelperVersion: EXT_HELPER_VERSION,
|
|
15
|
+
lastTemplateVersion,
|
|
16
|
+
cliCommands: CLI_COMMANDS_MAP,
|
|
17
|
+
managedTemplates: MANAGED_TEMPLATES,
|
|
18
|
+
templatesDir: TEMPLATES_DIR,
|
|
19
|
+
});
|
|
20
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { CLI_COMMANDS_MAP } from '../../constants.js';
|
|
3
|
+
import { resolveDependencies } from '../../dependencies/resolveDependencies.js';
|
|
4
|
+
import { LAST_TEMPLATE_VERSION } from '../../templates/templates.js';
|
|
5
|
+
import { getIsValidProjectConfig } from './getIsValidProjectConfig.js';
|
|
6
|
+
describe('isValidProjectConfig', () => {
|
|
7
|
+
const language = 'ts';
|
|
8
|
+
const framework = 'preact';
|
|
9
|
+
const { dependencies, devDependencies } = resolveDependencies(language, framework);
|
|
10
|
+
const baseConfig = {
|
|
11
|
+
cliCommands: CLI_COMMANDS_MAP,
|
|
12
|
+
name: 'project-name',
|
|
13
|
+
packageManager: 'npm',
|
|
14
|
+
framework,
|
|
15
|
+
language,
|
|
16
|
+
category: 'chat-bots',
|
|
17
|
+
dependencies,
|
|
18
|
+
devDependencies,
|
|
19
|
+
extHelperVersion: '0.0.0-test',
|
|
20
|
+
slots: ['EXTENSION_SLOT_MAIN_GAME_FUN', 'EXTENSION_SLOT_BACKGROUND'],
|
|
21
|
+
managedFiles: [],
|
|
22
|
+
lastTemplateVersion: LAST_TEMPLATE_VERSION,
|
|
23
|
+
};
|
|
24
|
+
it('return true if config project is valid', () => {
|
|
25
|
+
expect(getIsValidProjectConfig(baseConfig)).toBe(true);
|
|
26
|
+
});
|
|
27
|
+
it('return false for non object type', () => {
|
|
28
|
+
expect(getIsValidProjectConfig('')).toBe(false);
|
|
29
|
+
});
|
|
30
|
+
it('return false for null', () => {
|
|
31
|
+
expect(getIsValidProjectConfig(null)).toBe(false);
|
|
32
|
+
});
|
|
33
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { getIsValidCategory } from '../../validators/getIsValidCategory.js';
|
|
2
|
+
import { getIsValidFramework } from '../../validators/getIsValidFramework.js';
|
|
3
|
+
import { getIsValidLanguage } from '../../validators/getIsValidLanguage.js';
|
|
4
|
+
import { getIsValidPackageManager } from '../../validators/getIsValidPackageManager.js';
|
|
5
|
+
import { validateName } from '../../validators/validateName.js';
|
|
6
|
+
import { validateSlots } from '../../validators/validateSlots.js';
|
|
7
|
+
export const validateProjectConfig = (projectConfig) => {
|
|
8
|
+
const { category, framework, language, name, packageManager, slots } = projectConfig;
|
|
9
|
+
const validateNameResult = validateName(name);
|
|
10
|
+
if (validateNameResult !== true) {
|
|
11
|
+
return validateNameResult;
|
|
12
|
+
}
|
|
13
|
+
if (!getIsValidFramework(framework)) {
|
|
14
|
+
return `Framework is invalid: ${framework}`;
|
|
15
|
+
}
|
|
16
|
+
if (!getIsValidLanguage(language)) {
|
|
17
|
+
return `Language is invalid: ${language}`;
|
|
18
|
+
}
|
|
19
|
+
if (!getIsValidCategory(category)) {
|
|
20
|
+
return `Category is invalid: ${category}`;
|
|
21
|
+
}
|
|
22
|
+
if (!getIsValidPackageManager(packageManager)) {
|
|
23
|
+
return 'Invalid package manager';
|
|
24
|
+
}
|
|
25
|
+
const validateSlotsResult = validateSlots(slots, category);
|
|
26
|
+
if (validateSlotsResult.invalid.length > 0 || validateSlotsResult.violations.length > 0) {
|
|
27
|
+
return `Invalid slots ${slots.join(', ')} for category: ${category}`;
|
|
28
|
+
}
|
|
29
|
+
return true;
|
|
30
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { CLI_COMMANDS_MAP, EXT_HELPER_VERSION, SLOT_RULES_BY_CATEGORY } from '../../constants.js';
|
|
3
|
+
import { MANAGED_TEMPLATES } from '../../templates/constants.js';
|
|
4
|
+
import { TEMPLATES_DIR } from '../../templates/templates.js';
|
|
5
|
+
import { buildProjectConfig } from '../buildProjectConfig.js';
|
|
6
|
+
import { validateProjectConfig } from './validateProjectConfig.js';
|
|
7
|
+
const baseValidConfig = buildProjectConfig({
|
|
8
|
+
slots: [...SLOT_RULES_BY_CATEGORY['games-and-fun'].requiredBase, 'EXTENSION_SLOT_RIGHT_OVERLAY'],
|
|
9
|
+
category: 'games-and-fun',
|
|
10
|
+
packageManager: 'npm',
|
|
11
|
+
framework: 'preact',
|
|
12
|
+
language: 'ts',
|
|
13
|
+
name: 'some-extension',
|
|
14
|
+
extHelperVersion: EXT_HELPER_VERSION,
|
|
15
|
+
lastTemplateVersion: 1,
|
|
16
|
+
cliCommands: CLI_COMMANDS_MAP,
|
|
17
|
+
managedTemplates: MANAGED_TEMPLATES,
|
|
18
|
+
templatesDir: TEMPLATES_DIR,
|
|
19
|
+
});
|
|
20
|
+
describe('validateProjectConfig', () => {
|
|
21
|
+
it('return true if valid', () => {
|
|
22
|
+
const result = validateProjectConfig(baseValidConfig);
|
|
23
|
+
expect(result).toBe(true);
|
|
24
|
+
});
|
|
25
|
+
describe('name validation', () => {
|
|
26
|
+
it('return error message if name is invalid', () => {
|
|
27
|
+
const invalidNameConfig = {
|
|
28
|
+
...baseValidConfig,
|
|
29
|
+
name: 'Invalid Name With Spaces', // invalid name format
|
|
30
|
+
};
|
|
31
|
+
const result = validateProjectConfig(invalidNameConfig);
|
|
32
|
+
expect(result).not.toBe(true);
|
|
33
|
+
expect(typeof result).toBe('string');
|
|
34
|
+
});
|
|
35
|
+
it('return error message if name is empty', () => {
|
|
36
|
+
const invalidNameConfig = {
|
|
37
|
+
...baseValidConfig,
|
|
38
|
+
name: '',
|
|
39
|
+
};
|
|
40
|
+
const result = validateProjectConfig(invalidNameConfig);
|
|
41
|
+
expect(result).not.toBe(true);
|
|
42
|
+
expect(typeof result).toBe('string');
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
describe('framework validation', () => {
|
|
46
|
+
it('return error message if framework is invalid', () => {
|
|
47
|
+
const invalidFrameworkConfig = {
|
|
48
|
+
...baseValidConfig,
|
|
49
|
+
framework: 'invalid-framework',
|
|
50
|
+
};
|
|
51
|
+
const result = validateProjectConfig(invalidFrameworkConfig);
|
|
52
|
+
expect(result).toBe('Framework is invalid: invalid-framework');
|
|
53
|
+
});
|
|
54
|
+
it('accept preact framework', () => {
|
|
55
|
+
const result = validateProjectConfig(baseValidConfig);
|
|
56
|
+
expect(result).toBe(true);
|
|
57
|
+
});
|
|
58
|
+
it('accept vanilla framework', () => {
|
|
59
|
+
const vanillaConfig = {
|
|
60
|
+
...baseValidConfig,
|
|
61
|
+
framework: 'vanilla',
|
|
62
|
+
};
|
|
63
|
+
const result = validateProjectConfig(vanillaConfig);
|
|
64
|
+
expect(result).toBe(true);
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
describe('language validation', () => {
|
|
68
|
+
it('return error message if language is invalid', () => {
|
|
69
|
+
const invalidLanguageConfig = {
|
|
70
|
+
...baseValidConfig,
|
|
71
|
+
language: 'python',
|
|
72
|
+
};
|
|
73
|
+
const result = validateProjectConfig(invalidLanguageConfig);
|
|
74
|
+
expect(result).toBe('Language is invalid: python');
|
|
75
|
+
});
|
|
76
|
+
it('accept typescript language', () => {
|
|
77
|
+
const result = validateProjectConfig(baseValidConfig);
|
|
78
|
+
expect(result).toBe(true);
|
|
79
|
+
});
|
|
80
|
+
it('accept javascript language', () => {
|
|
81
|
+
const jsConfig = {
|
|
82
|
+
...baseValidConfig,
|
|
83
|
+
language: 'js',
|
|
84
|
+
};
|
|
85
|
+
const result = validateProjectConfig(jsConfig);
|
|
86
|
+
expect(result).toBe(true);
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
describe('category validation', () => {
|
|
90
|
+
it('return error message if category is invalid', () => {
|
|
91
|
+
const invalidCategoryConfig = {
|
|
92
|
+
...baseValidConfig,
|
|
93
|
+
category: 'invalid-category',
|
|
94
|
+
};
|
|
95
|
+
const result = validateProjectConfig(invalidCategoryConfig);
|
|
96
|
+
expect(result).toBe('Category is invalid: invalid-category');
|
|
97
|
+
});
|
|
98
|
+
it('accept games-and-fun category', () => {
|
|
99
|
+
const result = validateProjectConfig(baseValidConfig);
|
|
100
|
+
expect(result).toBe(true);
|
|
101
|
+
});
|
|
102
|
+
it('accept sex-toys category', () => {
|
|
103
|
+
const sexToysConfig = {
|
|
104
|
+
...baseValidConfig,
|
|
105
|
+
category: 'sex-toys',
|
|
106
|
+
slots: [...SLOT_RULES_BY_CATEGORY['sex-toys'].requiredBase, 'EXTENSION_SLOT_RIGHT_OVERLAY'],
|
|
107
|
+
};
|
|
108
|
+
const result = validateProjectConfig(sexToysConfig);
|
|
109
|
+
expect(result).toBe(true);
|
|
110
|
+
});
|
|
111
|
+
it('accept chat-bots category', () => {
|
|
112
|
+
const chatBotsConfig = {
|
|
113
|
+
...baseValidConfig,
|
|
114
|
+
category: 'chat-bots',
|
|
115
|
+
slots: [...SLOT_RULES_BY_CATEGORY['chat-bots'].requiredBase],
|
|
116
|
+
};
|
|
117
|
+
const result = validateProjectConfig(chatBotsConfig);
|
|
118
|
+
expect(result).toBe(true);
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
describe('package manager validation', () => {
|
|
122
|
+
it('return error message if package manager is invalid', () => {
|
|
123
|
+
const invalidPackageManagerConfig = {
|
|
124
|
+
...baseValidConfig,
|
|
125
|
+
packageManager: 'invalid-pm',
|
|
126
|
+
};
|
|
127
|
+
const result = validateProjectConfig(invalidPackageManagerConfig);
|
|
128
|
+
expect(result).toBe('Invalid package manager');
|
|
129
|
+
});
|
|
130
|
+
it('accept npm package manager', () => {
|
|
131
|
+
const result = validateProjectConfig(baseValidConfig);
|
|
132
|
+
expect(result).toBe(true);
|
|
133
|
+
});
|
|
134
|
+
it('accept yarn package manager', () => {
|
|
135
|
+
const yarnConfig = {
|
|
136
|
+
...baseValidConfig,
|
|
137
|
+
packageManager: 'yarn',
|
|
138
|
+
};
|
|
139
|
+
const result = validateProjectConfig(yarnConfig);
|
|
140
|
+
expect(result).toBe(true);
|
|
141
|
+
});
|
|
142
|
+
it('accept pnpm package manager', () => {
|
|
143
|
+
const pnpmConfig = {
|
|
144
|
+
...baseValidConfig,
|
|
145
|
+
packageManager: 'pnpm',
|
|
146
|
+
};
|
|
147
|
+
const result = validateProjectConfig(pnpmConfig);
|
|
148
|
+
expect(result).toBe(true);
|
|
149
|
+
});
|
|
150
|
+
it('accept bun package manager', () => {
|
|
151
|
+
const bunConfig = {
|
|
152
|
+
...baseValidConfig,
|
|
153
|
+
packageManager: 'bun',
|
|
154
|
+
};
|
|
155
|
+
const result = validateProjectConfig(bunConfig);
|
|
156
|
+
expect(result).toBe(true);
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
describe('slots validation', () => {
|
|
160
|
+
it('fails when slots are invalid for category', () => {
|
|
161
|
+
const invalidSlotsConfig = {
|
|
162
|
+
...baseValidConfig,
|
|
163
|
+
slots: ['invalid-slot'],
|
|
164
|
+
};
|
|
165
|
+
const result = validateProjectConfig(invalidSlotsConfig);
|
|
166
|
+
expect(result).toBe('Invalid slots invalid-slot for category: games-and-fun');
|
|
167
|
+
});
|
|
168
|
+
it('fails when required slots for category are missing', () => {
|
|
169
|
+
const invalidSlotsConfig = {
|
|
170
|
+
...baseValidConfig,
|
|
171
|
+
category: 'games-and-fun',
|
|
172
|
+
slots: [],
|
|
173
|
+
};
|
|
174
|
+
const result = validateProjectConfig(invalidSlotsConfig);
|
|
175
|
+
expect(result).toBe('Invalid slots for category: games-and-fun');
|
|
176
|
+
});
|
|
177
|
+
it('accept valid overlay slot for games-and-fun category', () => {
|
|
178
|
+
const result = validateProjectConfig(baseValidConfig);
|
|
179
|
+
expect(result).toBe(true);
|
|
180
|
+
});
|
|
181
|
+
it('accept another overlay slot for games-and-fun category', () => {
|
|
182
|
+
const validSlotsConfig = {
|
|
183
|
+
...baseValidConfig,
|
|
184
|
+
slots: [
|
|
185
|
+
...SLOT_RULES_BY_CATEGORY['games-and-fun'].requiredBase,
|
|
186
|
+
'EXTENSION_SLOT_VIDEO_DECORATIVE_OVERLAY',
|
|
187
|
+
],
|
|
188
|
+
};
|
|
189
|
+
const result = validateProjectConfig(validSlotsConfig);
|
|
190
|
+
expect(result).toBe(true);
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
describe('combined validations', () => {
|
|
194
|
+
it('return first validation error when multiple fields are invalid', () => {
|
|
195
|
+
const multipleInvalidConfig = {
|
|
196
|
+
...baseValidConfig,
|
|
197
|
+
name: 'Invalid Name',
|
|
198
|
+
framework: 'invalid-framework',
|
|
199
|
+
};
|
|
200
|
+
const result = validateProjectConfig(multipleInvalidConfig);
|
|
201
|
+
// Should return the first error (name validation runs first)
|
|
202
|
+
expect(result).not.toBe(true);
|
|
203
|
+
expect(typeof result).toBe('string');
|
|
204
|
+
});
|
|
205
|
+
it('return error when both framework and slots are invalid', () => {
|
|
206
|
+
const multipleInvalidConfig = {
|
|
207
|
+
...baseValidConfig,
|
|
208
|
+
framework: 'invalid-framework',
|
|
209
|
+
slots: [],
|
|
210
|
+
};
|
|
211
|
+
const result = validateProjectConfig(multipleInvalidConfig);
|
|
212
|
+
expect(result).toBe('Framework is invalid: invalid-framework');
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import ejs from 'ejs';
|
|
2
|
+
import { copyFileSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { dirname } from 'node:path';
|
|
4
|
+
const renderTemplate = (templatePath, data) => {
|
|
5
|
+
const template = readFileSync(templatePath, 'utf-8');
|
|
6
|
+
return ejs.render(template, data, { filename: templatePath });
|
|
7
|
+
};
|
|
8
|
+
export const executeCommands = (commands, cb) => {
|
|
9
|
+
for (const command of commands) {
|
|
10
|
+
mkdirSync(dirname(command.destPath), { recursive: true });
|
|
11
|
+
cb?.(command);
|
|
12
|
+
if (command.type === 'render') {
|
|
13
|
+
const content = renderTemplate(command.srcPath, command.data);
|
|
14
|
+
writeFileSync(command.destPath, content, 'utf-8');
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
if (command.type === 'copy') {
|
|
18
|
+
copyFileSync(command.srcPath, command.destPath);
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|