Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
dist
node_modules
src-old/
test-old/
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,14 @@ Where the provided flags are:

### Usage - Custom Mode

This mode provides full control over the assets used to generate icons and splash screens, but requires more source files. To use this mode, provide custom icons and splash screen source images as shown below:
This mode provides full control over the assets used to generate icons, banners and splash screens, but requires more source files. To use this mode, provide custom icons, banners and splash screen source images as shown below:

```
assets/
├── icon-only.png
├── icon-foreground.png
├── icon-background.png
├── banner.png
├── splash.png
└── splash-dark.png
```
Expand Down
19 changes: 19 additions & 0 deletions dist/asset-generator.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import type { InputAsset } from './input-asset';
import type { OutputAsset } from './output-asset';
import type { Project } from './project';
export declare abstract class AssetGenerator {
options: AssetGeneratorOptions;
constructor(options: AssetGeneratorOptions);
abstract generate(asset: InputAsset, project: Project): Promise<OutputAsset[]>;
}
export interface AssetGeneratorOptions {
iconBackgroundColor?: string;
iconBackgroundColorDark?: string;
splashBackgroundColor?: string;
splashBackgroundColorDark?: string;
pwaManifestPath?: string;
pwaNoAppleFetch?: boolean;
logoSplashScale?: number;
logoSplashTargetWidth?: number;
androidFlavor?: string;
}
9 changes: 9 additions & 0 deletions dist/asset-generator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AssetGenerator = void 0;
class AssetGenerator {
constructor(options) {
this.options = options;
}
}
exports.AssetGenerator = AssetGenerator;
23 changes: 23 additions & 0 deletions dist/colors.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import kleur from 'kleur';
export declare const strong: kleur.Color;
export declare const weak: kleur.Color;
export declare const input: kleur.Color;
export declare const success: kleur.Color;
export declare const failure: kleur.Color;
export declare const ancillary: kleur.Color;
export declare const extra: kleur.Color;
declare const COLORS: {
strong: kleur.Color;
weak: kleur.Color;
input: kleur.Color;
success: kleur.Color;
failure: kleur.Color;
ancillary: kleur.Color;
log: {
DEBUG: kleur.Color;
INFO: kleur.Color;
WARN: kleur.Color;
ERROR: kleur.Color;
};
};
export default COLORS;
27 changes: 27 additions & 0 deletions dist/colors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.extra = exports.ancillary = exports.failure = exports.success = exports.input = exports.weak = exports.strong = void 0;
const tslib_1 = require("tslib");
const kleur_1 = (0, tslib_1.__importDefault)(require("kleur"));
exports.strong = kleur_1.default.bold;
exports.weak = kleur_1.default.dim;
exports.input = kleur_1.default.cyan;
exports.success = kleur_1.default.green;
exports.failure = kleur_1.default.red;
exports.ancillary = kleur_1.default.cyan;
exports.extra = kleur_1.default.yellow;
const COLORS = {
strong: exports.strong,
weak: exports.weak,
input: exports.input,
success: exports.success,
failure: exports.failure,
ancillary: exports.ancillary,
log: {
DEBUG: kleur_1.default.magenta,
INFO: kleur_1.default.cyan,
WARN: kleur_1.default.yellow,
ERROR: kleur_1.default.red,
},
};
exports.default = COLORS;
11 changes: 11 additions & 0 deletions dist/ctx.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type { AssetGeneratorOptions } from './asset-generator';
import { Project } from './project';
export interface Context {
projectRootPath?: string;
args: AssetGeneratorOptions | any;
project: Project;
nodePackageRoot: string;
rootDir: string;
}
export declare function loadContext(projectRootPath?: string): Promise<Context>;
export declare function setArguments(ctx: Context, args: any): void;
52 changes: 52 additions & 0 deletions dist/ctx.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.setArguments = exports.loadContext = void 0;
const tslib_1 = require("tslib");
const path_1 = require("path");
const yargs_1 = (0, tslib_1.__importDefault)(require("yargs"));
const helpers_1 = require("yargs/helpers");
const project_1 = require("./project");
async function loadContext(projectRootPath) {
var _a;
const rootDir = process.cwd();
const argv = (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv)).argv;
let project;
try {
project = await loadProject(argv, projectRootPath, (_a = argv.assetPath) !== null && _a !== void 0 ? _a : 'assets');
}
catch (e) {
throw new Error(`Unable to load project: ${e.message}`);
}
return {
args: argv,
project,
projectRootPath,
// Important for resolving custom prettier plugin
nodePackageRoot: (0, path_1.join)(__dirname, '../../'),
rootDir,
};
}
exports.loadContext = loadContext;
function setArguments(ctx, args) {
ctx.args = args;
process.env.VERBOSE = '' + !!args.verbose;
}
exports.setArguments = setArguments;
async function loadProject(args, projectRootPath, projectAssetPath) {
const config = await loadMobileProjectConfig(args);
const project = new project_1.Project(projectRootPath, config, projectAssetPath);
await project.load();
return project;
}
// TODO: Use the config loading stuff from @capacitor/configure
function loadMobileProjectConfig(args) {
var _a, _b;
return {
ios: {
path: (_a = args.iosProject) !== null && _a !== void 0 ? _a : 'ios/App',
},
android: {
path: (_b = args.androidProject) !== null && _b !== void 0 ? _b : 'android',
},
};
}
152 changes: 152 additions & 0 deletions dist/definitions.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
import type { InputAsset } from './input-asset';
export interface Assets {
logo: InputAsset | null;
logoDark: InputAsset | null;
icon: InputAsset | null;
iconForeground: InputAsset | null;
iconBackground: InputAsset | null;
splash: InputAsset | null;
splashDark: InputAsset | null;
iosIcon?: InputAsset | null;
iosSplash?: InputAsset | null;
iosSplashDark?: InputAsset | null;
androidIcon?: InputAsset | null;
androidIconForeground?: InputAsset | null;
androidIconBackground?: InputAsset | null;
androidBanner?: InputAsset | null;
androidSplash?: InputAsset | null;
androidSplashDark?: InputAsset | null;
androidNotificationIcon?: InputAsset | null;
pwaIcon?: InputAsset | null;
pwaSplash?: InputAsset | null;
pwaSplashDark?: InputAsset | null;
}
export declare const enum AssetKind {
Logo = "logo",
LogoDark = "logo-dark",
AdaptiveIcon = "adaptive-icon",
Icon = "icon",
IconForeground = "icon-foreground",
IconBackground = "icon-background",
NotificationIcon = "notification-icon",
Banner = "banner",
Splash = "splash",
SplashDark = "splash-dark"
}
export declare const enum Platform {
Any = "any",
Ios = "ios",
Android = "android",
Pwa = "pwa"
}
export declare const enum Format {
Png = "png",
Jpeg = "jpeg",
Svg = "svg",
WebP = "webp",
Unknown = "unknown"
}
export declare const enum Orientation {
Default = "",
Portrait = "portrait",
Landscape = "landscape"
}
export declare const enum Theme {
Any = "any",
Light = "light",
Dark = "dark"
}
export declare const enum AndroidDensity {
Default = "",
Ldpi = "ldpi",
Mdpi = "mdpi",
Hdpi = "hdpi",
Xhdpi = "xhdpi",
Xxhdpi = "xxhdpi",
Xxxhdpi = "xxxhdpi",
LandLdpi = "land-ldpi",
LandMdpi = "land-mdpi",
LandHdpi = "land-hdpi",
LandXhdpi = "land-xhdpi",
LandXxhdpi = "land-xxhdpi",
LandXxxhdpi = "land-xxxhdpi",
PortLdpi = "port-ldpi",
PortMdpi = "port-mdpi",
PortHdpi = "port-hdpi",
PortXhdpi = "port-xhdpi",
PortXxhdpi = "port-xxhdpi",
PortXxxhdpi = "port-xxxhdpi",
DefaultNight = "night",
LdpiNight = "night-ldpi",
MdpiNight = "night-mdpi",
HdpiNight = "night-hdpi",
XhdpiNight = "night-xhdpi",
XxhdpiNight = "night-xxhdpi",
XxxhdpiNight = "night-xxxhdpi",
LandLdpiNight = "land-night-ldpi",
LandMdpiNight = "land-night-mdpi",
LandHdpiNight = "land-night-hdpi",
LandXhdpiNight = "land-night-xhdpi",
LandXxhdpiNight = "land-night-xxhdpi",
LandXxxhdpiNight = "land-night-xxxhdpi",
PortLdpiNight = "port-night-ldpi",
PortMdpiNight = "port-night-mdpi",
PortHdpiNight = "port-night-hdpi",
PortXhdpiNight = "port-night-xhdpi",
PortXxhdpiNight = "port-night-xxhdpi",
PortXxxhdpiNight = "port-night-xxxhdpi"
}
export interface OutputAssetTemplate {
platform: Platform;
kind: AssetKind;
format: Format;
width: number;
height: number;
scale?: number;
}
export interface IosOutputAssetTemplate extends OutputAssetTemplate {
name: string;
idiom: IosIdiom;
}
export declare const enum IosIdiom {
Universal = "universal",
iPhone = "iphone",
iPad = "ipad",
Watch = "watch",
TV = "tv"
}
export declare type IosOutputAssetTemplateIcon = IosOutputAssetTemplate;
export interface IosOutputAssetTemplateSplash extends IosOutputAssetTemplate {
orientation: Orientation;
theme: Theme;
}
export interface PwaOutputAssetTemplate extends OutputAssetTemplate {
name: string;
orientation?: Orientation;
density?: string;
}
export interface AndroidOutputAssetTemplate extends OutputAssetTemplate {
density: AndroidDensity;
}
export interface AndroidOutputAssetTemplateBanner extends OutputAssetTemplate {
density: AndroidDensity;
}
export interface AndroidOutputAssetTemplateSplash extends OutputAssetTemplate {
density: AndroidDensity;
orientation: Orientation;
}
export interface AndroidOutputAssetTemplateAdaptiveIcon extends OutputAssetTemplate {
density: AndroidDensity;
}
export interface IosContents {
images: {
filename: string;
size: string;
scale: string;
idiom: string;
}[];
info?: {
version: number;
author: string;
};
}
2 changes: 2 additions & 0 deletions dist/definitions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
18 changes: 18 additions & 0 deletions dist/error.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export declare abstract class BaseError extends Error {
readonly message: string;
abstract readonly name: string;
abstract readonly code: string;
constructor(message: string);
toString(): string;
toJSON(): {
[key: string]: any;
};
}
export declare class BadProjectError extends BaseError {
readonly name = "BadProjectError";
readonly code = "BAD_PROJECT";
}
export declare class BadPipelineError extends BaseError {
readonly name = "BadPipelineError";
readonly code = "BAD_SHARP_PIPELINE";
}
37 changes: 37 additions & 0 deletions dist/error.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BadPipelineError = exports.BadProjectError = exports.BaseError = void 0;
class BaseError extends Error {
constructor(message) {
super(message);
this.message = message;
this.stack = new Error().stack || '';
this.message = message;
}
toString() {
return this.message;
}
toJSON() {
return {
code: this.code,
message: this.message,
};
}
}
exports.BaseError = BaseError;
class BadProjectError extends BaseError {
constructor() {
super(...arguments);
this.name = 'BadProjectError';
this.code = 'BAD_PROJECT';
}
}
exports.BadProjectError = BadProjectError;
class BadPipelineError extends BaseError {
constructor() {
super(...arguments);
this.name = 'BadPipelineError';
this.code = 'BAD_SHARP_PIPELINE';
}
}
exports.BadPipelineError = BadPipelineError;
3 changes: 3 additions & 0 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import type { Context } from './ctx';
export declare function run(): Promise<void>;
export declare function runProgram(ctx: Context): void;
Loading