refactor!: remove next.js (#3267)

This commit is contained in:
Alex Yang
2023-07-19 00:53:10 +08:00
committed by GitHub
parent 79227a1e7c
commit 47f12f77f2
296 changed files with 4115 additions and 3617 deletions

View File

@@ -0,0 +1,16 @@
#!/usr/bin/env node
import { spawnSync } from 'node:child_process';
import { fileURLToPath } from 'node:url';
const child = spawnSync(
process.execPath,
[
'--loader',
'ts-node/esm/transpile-only',
fileURLToPath(new URL('./build-core.ts', import.meta.url)),
...process.argv.slice(2),
],
{ stdio: 'inherit' }
);
if (child.status) process.exit(child.status);

View File

@@ -0,0 +1,48 @@
import { spawn } from 'node:child_process';
import path from 'node:path';
import type { BuildFlags } from '../config/index.js';
import { projectRoot } from '../config/index.js';
const cwd = path.resolve(projectRoot, 'apps', 'core');
const getChannel = () => {
switch (process.env.BUILD_TYPE) {
case 'canary':
case 'beta':
case 'stable':
case 'internal':
return process.env.BUILD_TYPE;
default: {
throw new Error(
'BUILD_TYPE must be one of canary, beta, stable, internal'
);
}
}
};
const flags = {
distribution: 'browser',
mode: 'production',
channel: getChannel(),
coverage: process.env.COVERAGE === 'true',
} satisfies BuildFlags;
spawn(
'node',
[
'--loader',
'ts-node/esm/transpile-only',
'../../node_modules/webpack/bin/webpack.js',
'--mode',
'production',
'--env',
'flags=' + Buffer.from(JSON.stringify(flags), 'utf-8').toString('hex'),
].filter((v): v is string => !!v),
{
cwd,
stdio: 'inherit',
shell: true,
env: process.env,
}
);

View File

@@ -0,0 +1,16 @@
#!/usr/bin/env node
import { spawnSync } from 'node:child_process';
import { fileURLToPath } from 'node:url';
const child = spawnSync(
process.execPath,
[
'--loader',
'ts-node/esm/transpile-only',
fileURLToPath(new URL('./dev-core.ts', import.meta.url)),
...process.argv.slice(2),
],
{ stdio: 'inherit' }
);
if (child.status) process.exit(child.status);

View File

@@ -0,0 +1,84 @@
import { spawn } from 'node:child_process';
import path from 'node:path';
import * as p from '@clack/prompts';
import { type BuildFlags, projectRoot } from '../config/index.js';
const cwd = path.resolve(projectRoot, 'apps', 'core');
const flags: BuildFlags = {
distribution: 'browser',
mode: 'development',
channel: 'canary',
coverage: false,
};
const buildFlags = await p.group(
{
mode: () =>
p.select({
message: 'Mode',
options: [
{
value: 'development',
},
{
value: 'production',
},
],
initialValue: 'development',
}),
channel: () =>
p.select({
message: 'Channel',
options: [
{
value: 'canary',
},
{
value: 'beta',
},
{
value: 'stable',
},
],
initialValue: 'canary',
}),
coverage: () =>
p.confirm({
message: 'Enable coverage',
initialValue: process.env.COVERAGE === 'true',
}),
},
{
onCancel: () => {
p.cancel('Operation cancelled.');
process.exit(0);
},
}
);
flags.mode = buildFlags.mode as any;
flags.channel = buildFlags.channel as any;
flags.coverage = buildFlags.coverage;
spawn(
'node',
[
'--loader',
'ts-node/esm/transpile-only',
'../../node_modules/webpack/bin/webpack.js',
flags.mode === 'development' ? 'serve' : undefined,
'--mode',
flags.mode === 'development' ? 'development' : 'production',
'--env',
'flags=' + Buffer.from(JSON.stringify(flags), 'utf-8').toString('hex'),
].filter((v): v is string => !!v),
{
cwd,
stdio: 'inherit',
shell: true,
env: process.env,
}
);