feat: add puzzle clear template runtime
This commit is contained in:
@@ -477,8 +477,14 @@ function getChangedFiles(baseRef) {
|
||||
const diffOutput = tryGit(['diff', '--name-only', '-z', baseRef, '--']) ?? '';
|
||||
const untrackedOutput =
|
||||
tryGit(['ls-files', '--others', '--exclude-standard', '-z', moduleSrcRoot]) ?? '';
|
||||
const untrackedBindingsOutput =
|
||||
tryGit(['ls-files', '--others', '--exclude-standard', '-z', bindingsRoot]) ?? '';
|
||||
return new Set(
|
||||
[...diffOutput.split(/\u0000/u), ...untrackedOutput.split(/\u0000/u)]
|
||||
[
|
||||
...diffOutput.split(/\u0000/u),
|
||||
...untrackedOutput.split(/\u0000/u),
|
||||
...untrackedBindingsOutput.split(/\u0000/u),
|
||||
]
|
||||
.map(normalizePath)
|
||||
.filter(Boolean),
|
||||
);
|
||||
|
||||
@@ -88,6 +88,29 @@ describe('dev utils env merge', () => {
|
||||
);
|
||||
});
|
||||
|
||||
test('本地短信 smoke 可以用 mock 验证码覆盖真实短信 provider 口径', () => {
|
||||
withTempEnvFiles(
|
||||
{
|
||||
'.env.local': [
|
||||
'SMS_AUTH_ENABLED=true',
|
||||
'SMS_AUTH_PROVIDER=mock',
|
||||
'SMS_AUTH_MOCK_VERIFY_CODE=123456',
|
||||
].join('\n'),
|
||||
},
|
||||
(_env, tempDir) => {
|
||||
const env = mergeApiServerEnv(tempDir, {
|
||||
SMS_AUTH_ENABLED: 'true',
|
||||
SMS_AUTH_PROVIDER: 'aliyun',
|
||||
SMS_AUTH_MOCK_VERIFY_CODE: '654321',
|
||||
});
|
||||
|
||||
expect(env.SMS_AUTH_ENABLED).toBe('true');
|
||||
expect(env.SMS_AUTH_PROVIDER).toBe('mock');
|
||||
expect(env.SMS_AUTH_MOCK_VERIFY_CODE).toBe('123456');
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
test('空外层 shell 变量不会遮蔽本地私密配置', () => {
|
||||
withTempEnvFiles(
|
||||
{
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
existsSync,
|
||||
readdirSync,
|
||||
readFileSync,
|
||||
realpathSync,
|
||||
statSync,
|
||||
watch,
|
||||
writeFileSync,
|
||||
@@ -1684,6 +1685,26 @@ function normalizePath(path) {
|
||||
return path.replace(/\\/gu, '/');
|
||||
}
|
||||
|
||||
function safeRealpath(pathValue) {
|
||||
try {
|
||||
return realpathSync(pathValue);
|
||||
} catch {
|
||||
return resolve(pathValue);
|
||||
}
|
||||
}
|
||||
|
||||
function isDirectModuleExecution(argv1, moduleUrl, resolvePath = safeRealpath) {
|
||||
if (!argv1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
return resolvePath(argv1) === resolvePath(fileURLToPath(moduleUrl));
|
||||
} catch {
|
||||
return resolve(argv1) === fileURLToPath(moduleUrl);
|
||||
}
|
||||
}
|
||||
|
||||
function buildSpacetimePublishArgs({database, server, preserveDatabase}) {
|
||||
const args = [
|
||||
'publish',
|
||||
@@ -1735,6 +1756,7 @@ export {
|
||||
createDevServerSpawnOptions,
|
||||
createWatchConfigs,
|
||||
isSpacetimePublishPermissionError,
|
||||
isDirectModuleExecution,
|
||||
parseSpacetimeToolVersion,
|
||||
parseArgs,
|
||||
shouldAcceptWatchEvent,
|
||||
@@ -1765,6 +1787,6 @@ async function main() {
|
||||
}
|
||||
}
|
||||
|
||||
if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
||||
if (isDirectModuleExecution(process.argv[1], import.meta.url)) {
|
||||
void main();
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
buildSpacetimePublishArgs,
|
||||
createDevServerSpawnOptions,
|
||||
createWatchConfigs,
|
||||
isDirectModuleExecution,
|
||||
isSpacetimePublishPermissionError,
|
||||
parseSpacetimeToolVersion,
|
||||
parseArgs,
|
||||
@@ -35,6 +36,19 @@ function workspaceSpacetimeVersionForTest() {
|
||||
}
|
||||
|
||||
describe('dev scheduler argument routing', () => {
|
||||
test('Windows junction 路径下的直接执行入口也能识别为当前模块', () => {
|
||||
const moduleUrl =
|
||||
'file:///F:/DevWorktrees/codex/worktrees/f584/Genarrative/scripts/dev.mjs';
|
||||
const argv1 =
|
||||
'C:\\Users\\wuxiangwanzi\\.codex\\worktrees\\f584\\Genarrative\\scripts\\dev.mjs';
|
||||
const resolvePath = (value) =>
|
||||
value.startsWith('C:\\Users\\')
|
||||
? 'F:\\DevWorktrees\\codex\\worktrees\\f584\\Genarrative\\scripts\\dev.mjs'
|
||||
: value;
|
||||
|
||||
expect(isDirectModuleExecution(argv1, moduleUrl, resolvePath)).toBe(true);
|
||||
});
|
||||
|
||||
test('完整 dev 栈覆盖前端代理到本次解析出的 api-server 地址', () => {
|
||||
const {command, explicitOptions, options} = parseArgs([], {
|
||||
GENARRATIVE_API_PORT: '8090',
|
||||
|
||||
Reference in New Issue
Block a user