rework misskey-js build to preserve original package structure
This commit is contained in:
parent
b8a3bd6182
commit
2faeabe79c
7 changed files with 55 additions and 15 deletions
|
|
@ -1,5 +1,26 @@
|
|||
import * as nodepath from 'path';
|
||||
|
||||
export const scriptsDir = import.meta.dirname;
|
||||
export const rootDir = nodepath.join(scriptsDir, '../');
|
||||
export const outDir = nodepath.join(rootDir, './built');
|
||||
const dirname = import.meta.dirname;
|
||||
|
||||
/** Root directory of the misskey-js project */
|
||||
export const rootDir = nodepath.join(dirname, '../');
|
||||
/** Output directory for fully-built library. */
|
||||
export const outDir = nodepath.join(rootDir, 'built');
|
||||
/** Working directory for builds. */
|
||||
export const buildDir = nodepath.join(rootDir, 'temp/built');
|
||||
|
||||
/** Source directory for "scripts" subpackage, containing pure-JS scripts. */
|
||||
export const scriptsSource = dirname;
|
||||
/** Source directory for "lib" subpackage, containing the actual library source. */
|
||||
export const libSource = nodepath.join(rootDir, 'src');
|
||||
/** Source directory for "test" subpackage, containing unit tests. */
|
||||
export const testSource = nodepath.join(rootDir, 'test');
|
||||
/** Source directory for "test-d" subpackage, containing non-built type tests. */
|
||||
export const testDSource = nodepath.join(rootDir, 'test-d');
|
||||
|
||||
/** Working directory for "lib" subpackage builds */
|
||||
export const libBuild = nodepath.join(buildDir, 'src');
|
||||
/** Working directory for "test" subpackage builds */
|
||||
export const testBuild = nodepath.join(buildDir, 'test');
|
||||
/** Working directory for "test-d" subpackage builds */
|
||||
export const testDBuild = nodepath.join(buildDir, 'test-d');
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
import { rm } from 'fs/promises';
|
||||
import { outDir } from './_common.mjs';
|
||||
import {buildDir, outDir} from './_common.mjs';
|
||||
|
||||
console.log(`Cleaning ${outDir}...`);
|
||||
console.log(`Cleaning working directory ${buildDir}...`);
|
||||
await rm(buildDir, { recursive: true, force: true });
|
||||
|
||||
console.log(`Cleaning output directory ${outDir}...`);
|
||||
await rm(outDir, { recursive: true, force: true });
|
||||
|
|
|
|||
12
packages/misskey-js/scripts/post-build.mjs
Normal file
12
packages/misskey-js/scripts/post-build.mjs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
import {libBuild, outDir, testDBuild, testDSource} from './_common.mjs';
|
||||
import {rm, cp} from 'fs/promises';
|
||||
|
||||
// Always clean the output, because artifacts are cached in the build directory instead.
|
||||
console.log(`Cleaning output directory ${outDir}...`);
|
||||
await rm(outDir, { recursive: true, force: true });
|
||||
|
||||
// Copy built lib to output directory.
|
||||
await cp(libBuild, outDir, { recursive: true });
|
||||
|
||||
// Stage test-d sources in the build directory so tsd will work.
|
||||
await cp(testDSource, testDBuild, { recursive: true });
|
||||
Loading…
Add table
Add a link
Reference in a new issue