修复企微通讯录生产导入兼容性(07-26-internal-ops-recovery-baseline)
这个提交包含在:
@@ -35,6 +35,10 @@ Reports contain counts and categories only; personal field values are never prin
|
||||
`);
|
||||
}
|
||||
|
||||
function readStdinBuffer() {
|
||||
return fs.readFileSync(0);
|
||||
}
|
||||
|
||||
function parseArgs(argv) {
|
||||
const options = {
|
||||
input: "-",
|
||||
@@ -258,7 +262,7 @@ async function main() {
|
||||
printHelp();
|
||||
return;
|
||||
}
|
||||
const parsed = await parseDirectoryExport(await fs.promises.readFile(0));
|
||||
const parsed = await parseDirectoryExport(readStdinBuffer());
|
||||
resources = createPrismaClient();
|
||||
const actorId = await resolveActorId(resources.prisma, options.actorEmployeeNo);
|
||||
const syncRun = await runWecomHrMasterSync({
|
||||
@@ -293,4 +297,5 @@ module.exports = {
|
||||
findHeaderRow,
|
||||
parseArgs,
|
||||
parseDirectoryExport,
|
||||
readStdinBuffer,
|
||||
};
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
const fs = require("node:fs");
|
||||
const ExcelJS = require("exceljs");
|
||||
|
||||
const {
|
||||
@@ -5,6 +6,7 @@ const {
|
||||
buildSafeReport,
|
||||
parseArgs,
|
||||
parseDirectoryExport,
|
||||
readStdinBuffer,
|
||||
} = require("../../../src/scripts/import-wecom-directory-export");
|
||||
|
||||
async function buildDirectoryWorkbook(rows) {
|
||||
@@ -39,6 +41,17 @@ async function buildDirectoryWorkbook(rows) {
|
||||
}
|
||||
|
||||
describe("WeCom directory export importer", () => {
|
||||
it("reads stdin through the fd-compatible synchronous API", () => {
|
||||
const expected = Buffer.from("synthetic-xlsx");
|
||||
const readFileSync = vi.spyOn(fs, "readFileSync").mockReturnValue(expected);
|
||||
try {
|
||||
expect(readStdinBuffer()).toBe(expected);
|
||||
expect(readFileSync).toHaveBeenCalledWith(0);
|
||||
} finally {
|
||||
readFileSync.mockRestore();
|
||||
}
|
||||
});
|
||||
|
||||
it("requires stdin, the apply environment gate, and an actor for apply", () => {
|
||||
const previous = process.env.WECOM_DIRECTORY_EXPORT_APPLY;
|
||||
delete process.env.WECOM_DIRECTORY_EXPORT_APPLY;
|
||||
|
||||
在新工单中引用
屏蔽一个用户