Skip to content
Draft
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
{{#node_version}}
FROM node:{{node_version}}-alpine as base
{{/node_version}}
{{^node_version}}
FROM node:16.18.0-alpine as base
{{/node_version}}

RUN apk --no-cache --virtual build-dependencies add bash

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,16 @@
"properties": {
"image": {
"type": "object",
"required": ["node_version", "include"],
"properties": {
"node_version": {
"description": "Docker image's node version.",
"type": "string"
},
"include": {
"description": "Files to include in docker image.",
"type": "array",
"items": {
"type": "string"
}
}
}
}
},
"local": {},
"vm": { }
}
}
},
"local": { },
"vm": { }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,10 @@
"properties": {
"strategies": {
"properties": {
"image": {
"type": "object",
"properties": {
"include": {
"description": "Files to include in docker image.",
"type": "array",
"items": {
"type": "string"
}
}
}
}
"image": { },
"local": { },
"vm": { }
}
}
},
"local": { },
"vm": { }
}
}
}
117 changes: 117 additions & 0 deletions packages/js/manifests/polywrap/src/formats/polywrap.build/0.3.0.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/* eslint-disable @typescript-eslint/naming-convention */
/* tslint:disable */
/**
* This file was automatically generated by json-schema-to-typescript.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
* and run json-schema-to-typescript to regenerate this file.
*/

export interface BuildManifest {
/**
* Polywrap build manifest format version.
*/
format: "0.3.0";
/**
* Custom build image configurations.
*/
strategies?: {
image?: Image;
local?: Local;
vm?: Vm;
};
/**
* Locally linked packages into docker build image.
*/
linked_packages?: {
/**
* Package name.
*/
name: string;
/**
* Path to linked package directory.
*/
path: string;
/**
* Ignore files matching this regex in linked package directory.
*/
filter?: string;
}[];
/**
* General configurations.
*/
config?: {
[k: string]: unknown;
};
__type: "BuildManifest";
}
/**
* Docker image strategy configuration
*/
export interface Image {
/**
* Docker image name.
*/
name?: string;
/**
* Additional files to include in build image.
*/
include?: string[];
/**
* Docker image file path.
*/
dockerfile?: string;
/**
* Configuration options for Docker Buildx, set to true for default value.
*/
buildx?:
| {
/**
* Path to cache directory, set to true for default value, set to false to disable caching.
*/
cache?: string | boolean;
/**
* Remove the builder instance.
*/
remove_builder?: boolean;
}
| boolean;
/**
* Remove the image.
*/
remove_image?: boolean;
[k: string]: unknown;
}
/**
* Local build strategy configuration
*/
export interface Local {
/**
* Shell script containing all build commands.
*/
build_script?: string;
}
/**
* Docker VM strategy configuration
*/
export interface Vm {
/**
* Additional files to include in project directory volume.
*/
include?: string[];
/**
* Docker image for the build VM
*/
image?:
| string
| {
/**
* Docker image file path.
*/
dockerfile?: string;
};
/**
* Shell script containing all build commands.
*/
build_script?: string;
[k: string]: unknown;
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,42 @@ import {
import {
BuildManifest as BuildManifest_0_2_0,
} from "./0.2.0";
import {
BuildManifest as BuildManifest_0_3_0,
} from "./0.3.0";

export {
BuildManifest_0_1_0,
BuildManifest_0_2_0,
BuildManifest_0_3_0,
};

export enum BuildManifestFormats {
// NOTE: Patch fix for backwards compatability
"v0.1" = "0.1",
"v0.1.0" = "0.1.0",
"v0.2.0" = "0.2.0",
"v0.3.0" = "0.3.0",
}

export const BuildManifestSchemaFiles: Record<string, string> = {
// NOTE: Patch fix for backwards compatability
"0.1": "formats/polywrap.build/0.1.0.json",
"0.1.0": "formats/polywrap.build/0.1.0.json",
"0.2.0": "formats/polywrap.build/0.2.0.json",
"0.3.0": "formats/polywrap.build/0.3.0.json",
}

export type AnyBuildManifest =
| BuildManifest_0_1_0
| BuildManifest_0_2_0
| BuildManifest_0_3_0



export type BuildManifest = BuildManifest_0_2_0;
export type BuildManifest = BuildManifest_0_3_0;

export const latestBuildManifestFormat = BuildManifestFormats["v0.2.0"]
export const latestBuildManifestFormat = BuildManifestFormats["v0.3.0"]

export { migrateBuildManifest } from "./migrate";

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/* eslint-disable @typescript-eslint/naming-convention */

import { BuildManifest as OldManifest } from "../0.2.0";
import {
BuildManifest as NewManifest,
Image,
Local,
Vm
} from "../0.3.0";

export function migrate(old: OldManifest): NewManifest {
let image: Image | undefined;
const oldImage = old.strategies?.image;

if (oldImage) {
// Patch
const patchImage: Pick<
Image,
"buildx" | "remove_image"
> = {
buildx: oldImage.buildx ?
(typeof oldImage.buildx === "object" ? {
cache: oldImage.buildx.cache,
remove_builder: oldImage.buildx.removeBuilder
} : oldImage.buildx)
: undefined,
remove_image: oldImage.removeImage,
};

// Delete
delete oldImage.buildx;
delete oldImage.removeImage;

// Combine
image = {
...oldImage,
...patchImage
};
}

let local: Local | undefined;
const oldLocal = old.strategies?.local;

if (oldLocal) {
local = {
build_script: oldLocal.scriptPath
};
}

let vm: Vm | undefined;
const oldVm = old.strategies?.vm;

if (oldVm) {
vm = {
include: oldVm.defaultIncludes,
image: oldVm.baseImage
};
}

return {
...old,
__type: "BuildManifest",
format: "0.3.0",
strategies: {
image,
local,
vm
},
};
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Migrator } from "../../../migrations";
import { migrate as migrate_0_1_0_to_0_2_0 } from "./0.1.0_to_0.2.0";
import { migrate as migrate_0_2_0_to_0_3_0 } from "./0.2.0_to_0.3.0";

export const migrators: Migrator[] = [
{
Expand All @@ -11,5 +12,10 @@ export const migrators: Migrator[] = [
from: "0.1.0",
to: "0.2.0",
migrate: migrate_0_1_0_to_0_2_0
},
{
from: "0.2.0",
to: "0.3.0",
migrate: migrate_0_2_0_to_0_3_0
}
];
];
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {

import BuildManifestSchema_0_1_0 from "@polywrap/polywrap-manifest-schemas/formats/polywrap.build/0.1.0.json";
import BuildManifestSchema_0_2_0 from "@polywrap/polywrap-manifest-schemas/formats/polywrap.build/0.2.0.json";
import BuildManifestSchema_0_3_0 from "@polywrap/polywrap-manifest-schemas/formats/polywrap.build/0.3.0.json";

import {
Schema,
Expand All @@ -28,6 +29,7 @@ const schemas: BuildManifestSchemas = {
"0.1": BuildManifestSchema_0_1_0,
"0.1.0": BuildManifestSchema_0_1_0,
"0.2.0": BuildManifestSchema_0_2_0,
"0.3.0": BuildManifestSchema_0_3_0,
};

const validator = new Validator();
Expand Down
Loading