@deploid/core 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config.d.ts +3 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +26 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/logger.d.ts +15 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +39 -0
- package/dist/logger.js.map +1 -0
- package/dist/pipeline.d.ts +12 -0
- package/dist/pipeline.d.ts.map +1 -0
- package/dist/pipeline.js +18 -0
- package/dist/pipeline.js.map +1 -0
- package/dist/plugin-loader.d.ts +5 -0
- package/dist/plugin-loader.d.ts.map +1 -0
- package/dist/plugin-loader.js +71 -0
- package/dist/plugin-loader.js.map +1 -0
- package/dist/types.d.ts +97 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +20 -0
- package/src/config.ts +29 -0
- package/src/index.ts +7 -0
- package/src/logger.ts +41 -0
- package/src/pipeline.ts +25 -0
- package/src/plugin-loader.ts +89 -0
- package/src/types.ts +69 -0
- package/tsconfig.json +8 -0
- package/tsconfig.tsbuildinfo +1 -0
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAI3C,wBAAsB,UAAU,CAAC,GAAG,GAAE,MAAsB,GAAG,OAAO,CAAC,aAAa,CAAC,CAgBpF"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
export async function loadConfig(cwd = process.cwd()) {
|
|
4
|
+
const candidates = [
|
|
5
|
+
'deploid.config.ts',
|
|
6
|
+
'deploid.config.js',
|
|
7
|
+
'deploid.config.mjs',
|
|
8
|
+
'deploid.config.cjs'
|
|
9
|
+
];
|
|
10
|
+
for (const filename of candidates) {
|
|
11
|
+
const full = path.join(cwd, filename);
|
|
12
|
+
if (fs.existsSync(full)) {
|
|
13
|
+
const mod = await import(pathToFileURL(full).href);
|
|
14
|
+
const cfg = (mod.default || mod);
|
|
15
|
+
return cfg;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
throw new Error('No deploid config found');
|
|
19
|
+
}
|
|
20
|
+
function pathToFileURL(p) {
|
|
21
|
+
const resolved = path.resolve(p);
|
|
22
|
+
const url = new URL('file://');
|
|
23
|
+
url.pathname = resolved;
|
|
24
|
+
return url;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,MAAc,OAAO,CAAC,GAAG,EAAE;IAC1D,MAAM,UAAU,GAAG;QACjB,mBAAmB;QACnB,mBAAmB;QACnB,oBAAoB;QACpB,oBAAoB;KACrB,CAAC;IACF,KAAK,MAAM,QAAQ,IAAI,UAAU,EAAE,CAAC;QAClC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;QACtC,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YACxB,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;YACnD,MAAM,GAAG,GAAG,CAAC,GAAG,CAAC,OAAO,IAAI,GAAG,CAAkB,CAAC;YAClD,OAAO,GAAG,CAAC;QACb,CAAC;IACH,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;AAC7C,CAAC;AAED,SAAS,aAAa,CAAC,CAAS;IAC9B,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IACjC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,CAAC;IAC/B,GAAG,CAAC,QAAQ,GAAG,QAAQ,CAAC;IACxB,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC"}
|
package/dist/logger.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type LogLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
2
|
+
export declare class Logger {
|
|
3
|
+
private level;
|
|
4
|
+
constructor(level?: LogLevel);
|
|
5
|
+
private shouldLog;
|
|
6
|
+
debug(message: string): void;
|
|
7
|
+
info(message: string): void;
|
|
8
|
+
warn(message: string): void;
|
|
9
|
+
error(message: string): void;
|
|
10
|
+
debugStep(step: string, details?: unknown): void;
|
|
11
|
+
debugCommand(command: string, args: string[], cwd?: string): void;
|
|
12
|
+
debugEnv(): void;
|
|
13
|
+
}
|
|
14
|
+
export declare const logger: Logger;
|
|
15
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAE3D,qBAAa,MAAM;IACL,OAAO,CAAC,KAAK;gBAAL,KAAK,GAAE,QAAiB;IAE5C,OAAO,CAAC,SAAS;IAKjB,KAAK,CAAC,OAAO,EAAE,MAAM;IACrB,IAAI,CAAC,OAAO,EAAE,MAAM;IACpB,IAAI,CAAC,OAAO,EAAE,MAAM;IACpB,KAAK,CAAC,OAAO,EAAE,MAAM;IAErB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO;IASzC,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,CAAC,EAAE,MAAM;IAO1D,QAAQ;CAMT;AAED,eAAO,MAAM,MAAM,QAAoE,CAAC"}
|
package/dist/logger.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export class Logger {
|
|
2
|
+
constructor(level = 'info') {
|
|
3
|
+
this.level = level;
|
|
4
|
+
}
|
|
5
|
+
shouldLog(level) {
|
|
6
|
+
const order = ['debug', 'info', 'warn', 'error'];
|
|
7
|
+
return order.indexOf(level) >= order.indexOf(this.level);
|
|
8
|
+
}
|
|
9
|
+
debug(message) { if (this.shouldLog('debug'))
|
|
10
|
+
console.log(`[debug] ${message}`); }
|
|
11
|
+
info(message) { if (this.shouldLog('info'))
|
|
12
|
+
console.log(`[info] ${message}`); }
|
|
13
|
+
warn(message) { if (this.shouldLog('warn'))
|
|
14
|
+
console.warn(`[warn] ${message}`); }
|
|
15
|
+
error(message) { if (this.shouldLog('error'))
|
|
16
|
+
console.error(`[error] ${message}`); }
|
|
17
|
+
debugStep(step, details) {
|
|
18
|
+
if (this.shouldLog('debug')) {
|
|
19
|
+
console.log(`[debug] STEP ${step}`);
|
|
20
|
+
if (details !== undefined) {
|
|
21
|
+
console.log(`[debug] details=${JSON.stringify(details, null, 2)}`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
debugCommand(command, args, cwd) {
|
|
26
|
+
if (this.shouldLog('debug')) {
|
|
27
|
+
const location = cwd ? ` (cwd=${cwd})` : '';
|
|
28
|
+
console.log(`[debug] CMD ${command} ${args.join(' ')}${location}`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
debugEnv() {
|
|
32
|
+
if (this.shouldLog('debug')) {
|
|
33
|
+
console.log(`[debug] env node=${process.version} platform=${process.platform} arch=${process.arch}`);
|
|
34
|
+
console.log(`[debug] env cwd=${process.cwd()}`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export const logger = new Logger(process.env.DEPLOID_LOG_LEVEL || 'info');
|
|
39
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,MAAM;IACjB,YAAoB,QAAkB,MAAM;QAAxB,UAAK,GAAL,KAAK,CAAmB;IAAG,CAAC;IAExC,SAAS,CAAC,KAAe;QAC/B,MAAM,KAAK,GAAe,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;QAC7D,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC3D,CAAC;IAED,KAAK,CAAC,OAAe,IAAI,IAAI,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;QAAE,OAAO,CAAC,GAAG,CAAC,WAAW,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;IAC1F,IAAI,CAA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AAO,CAAC,OAAO,aAAa,OAAO,CAAC,QAAQ,SAAS,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;YACrG,OAAO,CAAC,GAAG,CAAC,mBAAmB,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;QAClD,CAAC;IACH,CAAC;CACF;AAED,MAAM,CAAC,MAAM,MAAM,GAAG,IAAI,MAAM,CAAE,OAAO,CAAC,GAAG,CAAC,iBAA8B,IAAI,MAAM,CAAC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Logger } from './logger.js';
|
|
2
|
+
import { DeploidConfig } from './types.js';
|
|
3
|
+
export type PipelineContext = {
|
|
4
|
+
cwd: string;
|
|
5
|
+
config: DeploidConfig;
|
|
6
|
+
logger: Logger;
|
|
7
|
+
debug?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export type PipelineStep = (ctx: PipelineContext) => Promise<void>;
|
|
10
|
+
export declare function runPipeline(ctx: PipelineContext, steps: PipelineStep[]): Promise<void>;
|
|
11
|
+
export declare function createContext(cwd: string, config: DeploidConfig, debug?: boolean): PipelineContext;
|
|
12
|
+
//# sourceMappingURL=pipeline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../src/pipeline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAU,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C,MAAM,MAAM,eAAe,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,aAAa,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AACtG,MAAM,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAEnE,wBAAsB,WAAW,CAAC,GAAG,EAAE,eAAe,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAY5F;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,KAAK,UAAQ,GAAG,eAAe,CAGhG"}
|
package/dist/pipeline.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Logger, logger } from './logger.js';
|
|
2
|
+
export async function runPipeline(ctx, steps) {
|
|
3
|
+
if (ctx.debug) {
|
|
4
|
+
ctx.logger.debugEnv();
|
|
5
|
+
ctx.logger.debug(`starting pipeline (${steps.length} steps)`);
|
|
6
|
+
}
|
|
7
|
+
for (let i = 0; i < steps.length; i++) {
|
|
8
|
+
if (ctx.debug) {
|
|
9
|
+
ctx.logger.debugStep(`${i + 1}/${steps.length}`);
|
|
10
|
+
}
|
|
11
|
+
await steps[i](ctx);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export function createContext(cwd, config, debug = false) {
|
|
15
|
+
const contextLogger = debug ? new Logger('debug') : logger;
|
|
16
|
+
return { cwd, config, logger: contextLogger, debug };
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=pipeline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline.js","sourceRoot":"","sources":["../src/pipeline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAM7C,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,GAAoB,EAAE,KAAqB;IAC3E,IAAI,GAAG,CAAC,KAAK,EAAE,CAAC;QACd,GAAG,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;QACtB,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,sBAAsB,KAAK,CAAC,MAAM,SAAS,CAAC,CAAC;IAChE,CAAC;IAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,IAAI,GAAG,CAAC,KAAK,EAAE,CAAC;YACd,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;QACnD,CAAC;QACD,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACtB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,GAAW,EAAE,MAAqB,EAAE,KAAK,GAAG,KAAK;IAC7E,MAAM,aAAa,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IAC3D,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC;AACvD,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { PipelineStep } from './pipeline.js';
|
|
2
|
+
import { DeploidConfig } from './types.js';
|
|
3
|
+
export declare function loadPlugin(pluginName: string, config: DeploidConfig): Promise<PipelineStep>;
|
|
4
|
+
export declare function loadPluginsFromConfig(config: DeploidConfig): Promise<PipelineStep[]>;
|
|
5
|
+
//# sourceMappingURL=plugin-loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-loader.d.ts","sourceRoot":"","sources":["../src/plugin-loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAiB,MAAM,YAAY,CAAC;AAG1D,wBAAsB,UAAU,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC,CAoBjG;AAED,wBAAsB,qBAAqB,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAa1F"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
export async function loadPlugin(pluginName, config) {
|
|
3
|
+
// Keep config in signature for future plugin selection hooks.
|
|
4
|
+
void config;
|
|
5
|
+
const packageName = `@deploid/plugin-${pluginName}`;
|
|
6
|
+
// First resolve plugin as an installed package.
|
|
7
|
+
try {
|
|
8
|
+
return instantiatePlugin(await import(packageName), pluginName);
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
// Fall through to monorepo/dev fallback.
|
|
12
|
+
}
|
|
13
|
+
// Fallback for monorepo/dev usage when packages are built locally.
|
|
14
|
+
const localPluginPath = new URL(`../../plugins/${pluginName}/dist/index.js`, import.meta.url).pathname;
|
|
15
|
+
if (existsSync(localPluginPath)) {
|
|
16
|
+
return instantiatePlugin(await import(localPluginPath), pluginName);
|
|
17
|
+
}
|
|
18
|
+
throw new Error(`Plugin "${pluginName}" not found. Expected package "${packageName}".`);
|
|
19
|
+
}
|
|
20
|
+
export async function loadPluginsFromConfig(config) {
|
|
21
|
+
const steps = [];
|
|
22
|
+
// Load plugins based on config
|
|
23
|
+
if (config.assets?.source) {
|
|
24
|
+
steps.push(await loadPlugin('assets', config));
|
|
25
|
+
}
|
|
26
|
+
// Load packaging plugin based on android.packaging
|
|
27
|
+
const packagingPlugin = `packaging-${config.android.packaging}`;
|
|
28
|
+
steps.push(await loadPlugin(packagingPlugin, config));
|
|
29
|
+
return steps;
|
|
30
|
+
}
|
|
31
|
+
function instantiatePlugin(mod, pluginName) {
|
|
32
|
+
if (mod.default && isPluginObject(mod.default)) {
|
|
33
|
+
return wrapPlugin(mod.default);
|
|
34
|
+
}
|
|
35
|
+
if (typeof mod.default === 'function') {
|
|
36
|
+
return mod.default();
|
|
37
|
+
}
|
|
38
|
+
const candidates = [
|
|
39
|
+
pluginName.replace(/-/g, ''),
|
|
40
|
+
`${pluginName.replace(/-/g, '')}Plugin`,
|
|
41
|
+
pluginName
|
|
42
|
+
];
|
|
43
|
+
for (const key of candidates) {
|
|
44
|
+
const value = mod[key];
|
|
45
|
+
if (value && isPluginObject(value)) {
|
|
46
|
+
return wrapPlugin(value);
|
|
47
|
+
}
|
|
48
|
+
if (typeof value === 'function') {
|
|
49
|
+
return value();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
throw new Error(`Plugin "${pluginName}" has no callable export.`);
|
|
53
|
+
}
|
|
54
|
+
function isPluginObject(value) {
|
|
55
|
+
return typeof value === 'object' && value !== null && 'run' in value && typeof value.run === 'function';
|
|
56
|
+
}
|
|
57
|
+
function wrapPlugin(plugin) {
|
|
58
|
+
return async (ctx) => {
|
|
59
|
+
if (plugin.plan) {
|
|
60
|
+
const plan = await plugin.plan({ cwd: ctx.cwd, config: ctx.config });
|
|
61
|
+
if (ctx.debug && plan.length) {
|
|
62
|
+
ctx.logger.debugStep(`plugin ${plugin.name} plan`, plan);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (plugin.validate) {
|
|
66
|
+
await plugin.validate({ cwd: ctx.cwd, config: ctx.config, logger: ctx.logger });
|
|
67
|
+
}
|
|
68
|
+
await plugin.run(ctx);
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=plugin-loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-loader.js","sourceRoot":"","sources":["../src/plugin-loader.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,UAAkB,EAAE,MAAqB;IACxE,8DAA8D;IAC9D,KAAK,MAAM,CAAC;IAEZ,MAAM,WAAW,GAAG,mBAAmB,UAAU,EAAE,CAAC;IAEpD,gDAAgD;IAChD,IAAI,CAAC;QACH,OAAO,iBAAiB,CAAC,MAAM,MAAM,CAAC,WAAW,CAAC,EAAE,UAAU,CAAC,CAAC;IAClE,CAAC;IAAC,MAAM,CAAC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CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;QAClF,CAAC;QAED,MAAM,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACxB,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
export type PackagingEngine = 'capacitor' | 'tauri' | 'twa';
|
|
2
|
+
export type ScreenOrientation = 'portrait' | 'landscape' | 'sensor' | 'sensorPortrait' | 'sensorLandscape' | 'fullSensor' | 'reversePortrait' | 'reverseLandscape';
|
|
3
|
+
export type LaunchMode = 'standard' | 'singleTop' | 'singleTask' | 'singleInstance';
|
|
4
|
+
export type StatusBarStyle = 'light' | 'dark' | 'auto';
|
|
5
|
+
export type WindowSoftInputMode = 'adjustResize' | 'adjustPan' | 'adjustNothing';
|
|
6
|
+
export interface DeploidConfig {
|
|
7
|
+
appName: string;
|
|
8
|
+
appId: string;
|
|
9
|
+
web: {
|
|
10
|
+
framework: 'vite' | 'next' | 'cra' | 'static';
|
|
11
|
+
buildCommand: string;
|
|
12
|
+
webDir: string;
|
|
13
|
+
pwa?: {
|
|
14
|
+
manifest?: string;
|
|
15
|
+
serviceWorker?: boolean;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
android: {
|
|
19
|
+
packaging: PackagingEngine;
|
|
20
|
+
targetSdk?: number;
|
|
21
|
+
minSdk?: number;
|
|
22
|
+
permissions?: string[];
|
|
23
|
+
signing?: {
|
|
24
|
+
keystorePath?: string;
|
|
25
|
+
alias?: string;
|
|
26
|
+
storePasswordEnv?: string;
|
|
27
|
+
keyPasswordEnv?: string;
|
|
28
|
+
};
|
|
29
|
+
version?: {
|
|
30
|
+
code: number;
|
|
31
|
+
name: string;
|
|
32
|
+
};
|
|
33
|
+
display?: {
|
|
34
|
+
fullscreen?: boolean;
|
|
35
|
+
immersive?: boolean;
|
|
36
|
+
orientation?: ScreenOrientation;
|
|
37
|
+
statusBarStyle?: StatusBarStyle;
|
|
38
|
+
statusBarHidden?: boolean;
|
|
39
|
+
navigationBarHidden?: boolean;
|
|
40
|
+
windowSoftInputMode?: WindowSoftInputMode;
|
|
41
|
+
};
|
|
42
|
+
launch?: {
|
|
43
|
+
launchMode?: LaunchMode;
|
|
44
|
+
taskAffinity?: string;
|
|
45
|
+
allowBackup?: boolean;
|
|
46
|
+
allowClearUserData?: boolean;
|
|
47
|
+
};
|
|
48
|
+
build?: {
|
|
49
|
+
enableProguard?: boolean;
|
|
50
|
+
enableMultidex?: boolean;
|
|
51
|
+
minifyEnabled?: boolean;
|
|
52
|
+
shrinkResources?: boolean;
|
|
53
|
+
buildType?: 'apk' | 'aab' | 'both';
|
|
54
|
+
};
|
|
55
|
+
performance?: {
|
|
56
|
+
hardwareAccelerated?: boolean;
|
|
57
|
+
largeHeap?: boolean;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
assets?: {
|
|
61
|
+
source: string;
|
|
62
|
+
output?: string;
|
|
63
|
+
};
|
|
64
|
+
publish?: {
|
|
65
|
+
play?: {
|
|
66
|
+
track?: 'internal' | 'alpha' | 'beta' | 'production';
|
|
67
|
+
serviceAccountJson?: string;
|
|
68
|
+
};
|
|
69
|
+
github?: {
|
|
70
|
+
repo: string;
|
|
71
|
+
draft?: boolean;
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
plugins?: string[];
|
|
75
|
+
}
|
|
76
|
+
export interface DeploidPlugin {
|
|
77
|
+
name: string;
|
|
78
|
+
requirements?: string[];
|
|
79
|
+
validate?: (ctx: {
|
|
80
|
+
cwd: string;
|
|
81
|
+
config: DeploidConfig;
|
|
82
|
+
logger: {
|
|
83
|
+
info: (msg: string) => void;
|
|
84
|
+
};
|
|
85
|
+
}) => Promise<void>;
|
|
86
|
+
plan?: (ctx: {
|
|
87
|
+
cwd: string;
|
|
88
|
+
config: DeploidConfig;
|
|
89
|
+
}) => Promise<string[]> | string[];
|
|
90
|
+
run: (ctx: {
|
|
91
|
+
cwd: string;
|
|
92
|
+
config: DeploidConfig;
|
|
93
|
+
logger: unknown;
|
|
94
|
+
debug?: boolean;
|
|
95
|
+
}) => Promise<void>;
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG,OAAO,GAAG,KAAK,CAAC;AAC5D,MAAM,MAAM,iBAAiB,GAAG,UAAU,GAAG,WAAW,GAAG,QAAQ,GAAG,gBAAgB,GAAG,iBAAiB,GAAG,YAAY,GAAG,iBAAiB,GAAG,kBAAkB,CAAC;AACnK,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,WAAW,GAAG,YAAY,GAAG,gBAAgB,CAAC;AACpF,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;AACvD,MAAM,MAAM,mBAAmB,GAAG,cAAc,GAAG,WAAW,GAAG,eAAe,CAAC;AAEjF,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE;QACH,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,CAAC;QAC9C,YAAY,EAAE,MAAM,CAAC;QACrB,MAAM,EAAE,MAAM,CAAC;QACf,GAAG,CAAC,EAAE;YAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;YAAC,aAAa,CAAC,EAAE,OAAO,CAAA;SAAE,CAAC;KACtD,CAAC;IACF,OAAO,EAAE;QACP,SAAS,EAAE,eAAe,CAAC;QAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,WAAW,CAAC,EAAE,MAAM,EAA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/core",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"type": "module",
|
|
9
|
+
"main": "dist/index.js",
|
|
10
|
+
"types": "dist/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"import": "./dist/index.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsc -b"
|
|
19
|
+
}
|
|
20
|
+
}
|
package/src/config.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { DeploidConfig } from './types.js';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
|
|
5
|
+
export async function loadConfig(cwd: string = process.cwd()): Promise<DeploidConfig> {
|
|
6
|
+
const candidates = [
|
|
7
|
+
'deploid.config.ts',
|
|
8
|
+
'deploid.config.js',
|
|
9
|
+
'deploid.config.mjs',
|
|
10
|
+
'deploid.config.cjs'
|
|
11
|
+
];
|
|
12
|
+
for (const filename of candidates) {
|
|
13
|
+
const full = path.join(cwd, filename);
|
|
14
|
+
if (fs.existsSync(full)) {
|
|
15
|
+
const mod = await import(pathToFileURL(full).href);
|
|
16
|
+
const cfg = (mod.default || mod) as DeploidConfig;
|
|
17
|
+
return cfg;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
throw new Error('No deploid config found');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function pathToFileURL(p: string): URL {
|
|
24
|
+
const resolved = path.resolve(p);
|
|
25
|
+
const url = new URL('file://');
|
|
26
|
+
url.pathname = resolved;
|
|
27
|
+
return url;
|
|
28
|
+
}
|
|
29
|
+
|
package/src/index.ts
ADDED
package/src/logger.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export type LogLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
2
|
+
|
|
3
|
+
export class Logger {
|
|
4
|
+
constructor(private level: LogLevel = 'info') {}
|
|
5
|
+
|
|
6
|
+
private shouldLog(level: LogLevel): boolean {
|
|
7
|
+
const order: LogLevel[] = ['debug', 'info', 'warn', 'error'];
|
|
8
|
+
return order.indexOf(level) >= order.indexOf(this.level);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
debug(message: string) { if (this.shouldLog('debug')) console.log(`[debug] ${message}`); }
|
|
12
|
+
info(message: string) { if (this.shouldLog('info')) console.log(`[info] ${message}`); }
|
|
13
|
+
warn(message: string) { if (this.shouldLog('warn')) console.warn(`[warn] ${message}`); }
|
|
14
|
+
error(message: string) { if (this.shouldLog('error')) console.error(`[error] ${message}`); }
|
|
15
|
+
|
|
16
|
+
debugStep(step: string, details?: unknown) {
|
|
17
|
+
if (this.shouldLog('debug')) {
|
|
18
|
+
console.log(`[debug] STEP ${step}`);
|
|
19
|
+
if (details !== undefined) {
|
|
20
|
+
console.log(`[debug] details=${JSON.stringify(details, null, 2)}`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
debugCommand(command: string, args: string[], cwd?: string) {
|
|
26
|
+
if (this.shouldLog('debug')) {
|
|
27
|
+
const location = cwd ? ` (cwd=${cwd})` : '';
|
|
28
|
+
console.log(`[debug] CMD ${command} ${args.join(' ')}${location}`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
debugEnv() {
|
|
33
|
+
if (this.shouldLog('debug')) {
|
|
34
|
+
console.log(`[debug] env node=${process.version} platform=${process.platform} arch=${process.arch}`);
|
|
35
|
+
console.log(`[debug] env cwd=${process.cwd()}`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export const logger = new Logger((process.env.DEPLOID_LOG_LEVEL as LogLevel) || 'info');
|
|
41
|
+
|
package/src/pipeline.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Logger, logger } from './logger.js';
|
|
2
|
+
import { DeploidConfig } from './types.js';
|
|
3
|
+
|
|
4
|
+
export type PipelineContext = { cwd: string; config: DeploidConfig; logger: Logger; debug?: boolean };
|
|
5
|
+
export type PipelineStep = (ctx: PipelineContext) => Promise<void>;
|
|
6
|
+
|
|
7
|
+
export async function runPipeline(ctx: PipelineContext, steps: PipelineStep[]): Promise<void> {
|
|
8
|
+
if (ctx.debug) {
|
|
9
|
+
ctx.logger.debugEnv();
|
|
10
|
+
ctx.logger.debug(`starting pipeline (${steps.length} steps)`);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
for (let i = 0; i < steps.length; i++) {
|
|
14
|
+
if (ctx.debug) {
|
|
15
|
+
ctx.logger.debugStep(`${i + 1}/${steps.length}`);
|
|
16
|
+
}
|
|
17
|
+
await steps[i](ctx);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function createContext(cwd: string, config: DeploidConfig, debug = false): PipelineContext {
|
|
22
|
+
const contextLogger = debug ? new Logger('debug') : logger;
|
|
23
|
+
return { cwd, config, logger: contextLogger, debug };
|
|
24
|
+
}
|
|
25
|
+
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { PipelineStep } from './pipeline.js';
|
|
2
|
+
import { DeploidConfig, DeploidPlugin } from './types.js';
|
|
3
|
+
import { existsSync } from 'node:fs';
|
|
4
|
+
|
|
5
|
+
export async function loadPlugin(pluginName: string, config: DeploidConfig): Promise<PipelineStep> {
|
|
6
|
+
// Keep config in signature for future plugin selection hooks.
|
|
7
|
+
void config;
|
|
8
|
+
|
|
9
|
+
const packageName = `@deploid/plugin-${pluginName}`;
|
|
10
|
+
|
|
11
|
+
// First resolve plugin as an installed package.
|
|
12
|
+
try {
|
|
13
|
+
return instantiatePlugin(await import(packageName), pluginName);
|
|
14
|
+
} catch {
|
|
15
|
+
// Fall through to monorepo/dev fallback.
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Fallback for monorepo/dev usage when packages are built locally.
|
|
19
|
+
const localPluginPath = new URL(`../../plugins/${pluginName}/dist/index.js`, import.meta.url).pathname;
|
|
20
|
+
if (existsSync(localPluginPath)) {
|
|
21
|
+
return instantiatePlugin(await import(localPluginPath), pluginName);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
throw new Error(`Plugin "${pluginName}" not found. Expected package "${packageName}".`);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export async function loadPluginsFromConfig(config: DeploidConfig): Promise<PipelineStep[]> {
|
|
28
|
+
const steps: PipelineStep[] = [];
|
|
29
|
+
|
|
30
|
+
// Load plugins based on config
|
|
31
|
+
if (config.assets?.source) {
|
|
32
|
+
steps.push(await loadPlugin('assets', config));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Load packaging plugin based on android.packaging
|
|
36
|
+
const packagingPlugin = `packaging-${config.android.packaging}`;
|
|
37
|
+
steps.push(await loadPlugin(packagingPlugin, config));
|
|
38
|
+
|
|
39
|
+
return steps;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function instantiatePlugin(mod: Record<string, unknown>, pluginName: string): PipelineStep {
|
|
43
|
+
if (mod.default && isPluginObject(mod.default)) {
|
|
44
|
+
return wrapPlugin(mod.default);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (typeof mod.default === 'function') {
|
|
48
|
+
return (mod.default as () => PipelineStep)();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const candidates = [
|
|
52
|
+
pluginName.replace(/-/g, ''),
|
|
53
|
+
`${pluginName.replace(/-/g, '')}Plugin`,
|
|
54
|
+
pluginName
|
|
55
|
+
];
|
|
56
|
+
|
|
57
|
+
for (const key of candidates) {
|
|
58
|
+
const value = mod[key];
|
|
59
|
+
if (value && isPluginObject(value)) {
|
|
60
|
+
return wrapPlugin(value);
|
|
61
|
+
}
|
|
62
|
+
if (typeof value === 'function') {
|
|
63
|
+
return (value as () => PipelineStep)();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
throw new Error(`Plugin "${pluginName}" has no callable export.`);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function isPluginObject(value: unknown): value is DeploidPlugin {
|
|
71
|
+
return typeof value === 'object' && value !== null && 'run' in value && typeof (value as { run: unknown }).run === 'function';
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function wrapPlugin(plugin: DeploidPlugin): PipelineStep {
|
|
75
|
+
return async (ctx) => {
|
|
76
|
+
if (plugin.plan) {
|
|
77
|
+
const plan = await plugin.plan({ cwd: ctx.cwd, config: ctx.config });
|
|
78
|
+
if (ctx.debug && plan.length) {
|
|
79
|
+
ctx.logger.debugStep(`plugin ${plugin.name} plan`, plan);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (plugin.validate) {
|
|
84
|
+
await plugin.validate({ cwd: ctx.cwd, config: ctx.config, logger: ctx.logger });
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
await plugin.run(ctx);
|
|
88
|
+
};
|
|
89
|
+
}
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
export type PackagingEngine = 'capacitor' | 'tauri' | 'twa';
|
|
2
|
+
export type ScreenOrientation = 'portrait' | 'landscape' | 'sensor' | 'sensorPortrait' | 'sensorLandscape' | 'fullSensor' | 'reversePortrait' | 'reverseLandscape';
|
|
3
|
+
export type LaunchMode = 'standard' | 'singleTop' | 'singleTask' | 'singleInstance';
|
|
4
|
+
export type StatusBarStyle = 'light' | 'dark' | 'auto';
|
|
5
|
+
export type WindowSoftInputMode = 'adjustResize' | 'adjustPan' | 'adjustNothing';
|
|
6
|
+
|
|
7
|
+
export interface DeploidConfig {
|
|
8
|
+
appName: string;
|
|
9
|
+
appId: string;
|
|
10
|
+
web: {
|
|
11
|
+
framework: 'vite' | 'next' | 'cra' | 'static';
|
|
12
|
+
buildCommand: string;
|
|
13
|
+
webDir: string;
|
|
14
|
+
pwa?: { manifest?: string; serviceWorker?: boolean };
|
|
15
|
+
};
|
|
16
|
+
android: {
|
|
17
|
+
packaging: PackagingEngine;
|
|
18
|
+
targetSdk?: number;
|
|
19
|
+
minSdk?: number;
|
|
20
|
+
permissions?: string[];
|
|
21
|
+
signing?: {
|
|
22
|
+
keystorePath?: string;
|
|
23
|
+
alias?: string;
|
|
24
|
+
storePasswordEnv?: string;
|
|
25
|
+
keyPasswordEnv?: string;
|
|
26
|
+
};
|
|
27
|
+
version?: { code: number; name: string };
|
|
28
|
+
display?: {
|
|
29
|
+
fullscreen?: boolean;
|
|
30
|
+
immersive?: boolean;
|
|
31
|
+
orientation?: ScreenOrientation;
|
|
32
|
+
statusBarStyle?: StatusBarStyle;
|
|
33
|
+
statusBarHidden?: boolean;
|
|
34
|
+
navigationBarHidden?: boolean;
|
|
35
|
+
windowSoftInputMode?: WindowSoftInputMode;
|
|
36
|
+
};
|
|
37
|
+
launch?: {
|
|
38
|
+
launchMode?: LaunchMode;
|
|
39
|
+
taskAffinity?: string;
|
|
40
|
+
allowBackup?: boolean;
|
|
41
|
+
allowClearUserData?: boolean;
|
|
42
|
+
};
|
|
43
|
+
build?: {
|
|
44
|
+
enableProguard?: boolean;
|
|
45
|
+
enableMultidex?: boolean;
|
|
46
|
+
minifyEnabled?: boolean;
|
|
47
|
+
shrinkResources?: boolean;
|
|
48
|
+
buildType?: 'apk' | 'aab' | 'both';
|
|
49
|
+
};
|
|
50
|
+
performance?: {
|
|
51
|
+
hardwareAccelerated?: boolean;
|
|
52
|
+
largeHeap?: boolean;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
assets?: { source: string; output?: string };
|
|
56
|
+
publish?: {
|
|
57
|
+
play?: { track?: 'internal' | 'alpha' | 'beta' | 'production'; serviceAccountJson?: string };
|
|
58
|
+
github?: { repo: string; draft?: boolean };
|
|
59
|
+
};
|
|
60
|
+
plugins?: string[];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface DeploidPlugin {
|
|
64
|
+
name: string;
|
|
65
|
+
requirements?: string[];
|
|
66
|
+
validate?: (ctx: { cwd: string; config: DeploidConfig; logger: { info: (msg: string) => void } }) => Promise<void>;
|
|
67
|
+
plan?: (ctx: { cwd: string; config: DeploidConfig }) => Promise<string[]> | string[];
|
|
68
|
+
run: (ctx: { cwd: string; config: DeploidConfig; logger: unknown; debug?: boolean }) => Promise<void>;
|
|
69
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"root":["./src/config.ts","./src/index.ts","./src/logger.ts","./src/pipeline.ts","./src/plugin-loader.ts","./src/types.ts"],"version":"5.9.3"}
|