Skip to content
This repository was archived by the owner on Nov 5, 2025. It is now read-only.
Merged
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
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"typings": "index",
"scripts": {
"start": "gulp",
"test": "npm run unit-tests",
"lint": "tslint --project tsconfig.json",
"fix-lint": "tslint --project tsconfig.json --fix",
"bundle": "gulp bundle",
Expand Down Expand Up @@ -85,6 +86,7 @@
"ts-node": "^6.2.0",
"tslint": "^5.11.0",
"typedoc": "^0.15.0",
"typescript": "^2.9.2",
"uglify-es": "^3.3.9"
},
"dependencies": {
Expand All @@ -93,7 +95,6 @@
"lodash.clonedeep": "^4.5.0",
"semver": "^5.5.0",
"stack-trace": "0.0.10",
"typescript": "^2.9.2",
"uuid": "^3.2.1"
},
"nyc": {
Expand Down
1 change: 1 addition & 0 deletions src/definition/metadata/IAppInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface IAppInfo {
author: IAppAuthorInfo;
classFile: string;
iconFile: string;
implements: Array<AppInterface>;
/** Base64 string of the App's icon. */
iconFileContent?: string;
essentials?: Array<AppInterface>;
Expand Down
41 changes: 14 additions & 27 deletions src/server/AppManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,19 +164,12 @@ export class AppManager {
const aff = new AppFabricationFulfillment();

try {
const result = await this.getParser().parseZip(this.getCompiler(), item.zip);
const result = await this.getParser().unpackageApp(Buffer.from(item.zip, 'base64'));

aff.setAppInfo(result.info);
aff.setImplementedInterfaces(result.implemented.getValues());
aff.setCompilerErrors(result.compilerErrors);

if (result.compilerErrors.length > 0) {
const errors = result.compilerErrors.map(({ message }) => message).join('\n');

throw new Error(`Failed to compile due to ${ result.compilerErrors.length } errors:\n${ errors }`);
}

item.compiled = result.compiledFiles;
item.compiled = result.files;

const app = this.getCompiler().toSandBox(this, item);
this.apps.set(item.id, app);
Expand Down Expand Up @@ -382,24 +375,23 @@ export class AppManager {
return true;
}

public async add(zipContentsBase64d: string, enable = true, marketplaceInfo?: IMarketplaceInfo): Promise<AppFabricationFulfillment> {
public async add(appPackage: Buffer, enable = true, marketplaceInfo?: IMarketplaceInfo): Promise<AppFabricationFulfillment> {
const aff = new AppFabricationFulfillment();
const result = await this.getParser().parseZip(this.getCompiler(), zipContentsBase64d);
const result = await this.getParser().unpackageApp(appPackage);

aff.setAppInfo(result.info);
aff.setImplementedInterfaces(result.implemented.getValues());
aff.setCompilerErrors(result.compilerErrors);

if (result.compilerErrors.length > 0) {
return aff;
}

const compiled = {
id: result.info.id,
info: result.info,
status: AppStatus.UNKNOWN,
zip: zipContentsBase64d,
compiled: result.compiledFiles,
zip: appPackage.toString('base64'),
// tslint:disable-next-line: max-line-length
compiled: Object.entries(result.files).reduce(
(files, [key, value]) => (files[key.replace(/\./gi, '$')] = value, files),
{} as {[key: string]: string},
),
languageContent: result.languageContent,
settings: {},
implemented: result.implemented.getValues(),
Expand Down Expand Up @@ -479,17 +471,12 @@ export class AppManager {
return app;
}

public async update(zipContentsBase64d: string): Promise<AppFabricationFulfillment> {
public async update(appPackage: Buffer): Promise<AppFabricationFulfillment> {
const aff = new AppFabricationFulfillment();
const result = await this.getParser().parseZip(this.getCompiler(), zipContentsBase64d);
const result = await this.getParser().unpackageApp(appPackage);

aff.setAppInfo(result.info);
aff.setImplementedInterfaces(result.implemented.getValues());
aff.setCompilerErrors(result.compilerErrors);

if (result.compilerErrors.length > 0) {
return aff;
}

const old = await this.storage.retrieveOne(result.info.id);

Expand All @@ -506,8 +493,8 @@ export class AppManager {
id: result.info.id,
info: result.info,
status: this.apps.get(old.id).getStatus(),
zip: zipContentsBase64d,
compiled: result.compiledFiles,
zip: appPackage.toString('base64'),
compiled: result.files,
languageContent: result.languageContent,
settings: old.settings,
implemented: result.implemented.getValues(),
Expand Down
Loading