✨feature: First push to git
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
import { chmod } from 'node:fs/promises';
|
||||
|
||||
await chmod('dist/index.js', 0o755).catch(() => undefined);
|
||||
@@ -0,0 +1,18 @@
|
||||
import { execFile } from 'node:child_process';
|
||||
import { platform } from 'node:os';
|
||||
import { join } from 'node:path';
|
||||
import { promisify } from 'node:util';
|
||||
|
||||
const exec = promisify(execFile);
|
||||
const isWindows = platform() === 'win32';
|
||||
const pkg = join(process.cwd(), 'node_modules', '@yao-pkg', 'pkg', 'lib-es5', 'bin.js');
|
||||
const target = isWindows
|
||||
? 'node22-win-x64'
|
||||
: platform() === 'darwin'
|
||||
? 'node22-macos-x64'
|
||||
: 'node22-linux-x64';
|
||||
const output = join('dist', isWindows ? 'nlc.exe' : 'nlc');
|
||||
|
||||
await exec(process.execPath, [pkg, 'dist/index.js', '--targets', target, '--output', output], {
|
||||
cwd: process.cwd()
|
||||
});
|
||||
@@ -0,0 +1,37 @@
|
||||
import { execFile } from 'node:child_process';
|
||||
import { mkdtemp, writeFile, rm } from 'node:fs/promises';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { join } from 'node:path';
|
||||
import { promisify } from 'node:util';
|
||||
|
||||
const exec = promisify(execFile);
|
||||
const cli = join(process.cwd(), 'dist', 'index.js');
|
||||
const binary = join(process.cwd(), 'dist', process.platform === 'win32' ? 'nlc.exe' : 'nlc');
|
||||
const dir = await mkdtemp(join(tmpdir(), 'nlc-smoke-'));
|
||||
|
||||
try {
|
||||
const config = join(dir, 'config.yaml');
|
||||
await writeFile(
|
||||
config,
|
||||
`gmail:
|
||||
folder: Newsletters
|
||||
output:
|
||||
name: Smoke Catalog
|
||||
excel:
|
||||
enabled: true
|
||||
path: ${JSON.stringify(join(dir, 'catalog.xlsx'))}
|
||||
state_file: ${JSON.stringify(join(dir, 'state.json'))}
|
||||
`
|
||||
);
|
||||
|
||||
await exec('node', [cli, '--help']);
|
||||
await exec(binary, ['--help']);
|
||||
await exec('node', [cli, 'init', '--help']);
|
||||
await exec('node', [cli, 'run', '--help']);
|
||||
await exec('node', [cli, 'run', '--config', config, '--dry-run'], {
|
||||
env: { ...process.env, NLC_FIXTURE: '1' }
|
||||
});
|
||||
console.log('Smoke checks passed');
|
||||
} finally {
|
||||
await rm(dir, { force: true, recursive: true });
|
||||
}
|
||||
Reference in New Issue
Block a user