Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove launcher #66

Merged
merged 1 commit into from
Feb 19, 2022
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: 1 addition & 2 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,4 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: node make launcher:build
- run: node make run-tests
- run: node make test
8 changes: 1 addition & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
node_modules/
build/
bin/
.vscode/
examples/*/www
.ionide/
obj/
bin/
dist/
.fable/
www/crochet.js
tsconfig.tsbuildinfo
versions/current.js
Expand All @@ -15,8 +12,5 @@ versions/current.js
stdlib/**/*.js
tools/**/native/*.js
_build
tools/launcher/www/crochet.js
tools/launcher/www/crochet-ipc.js
tools/launcher/www/monaco/
*.lingua.crochet
*:Zone.Identifier
174 changes: 0 additions & 174 deletions make.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,5 @@
#!/usr/bin/env node
const FS = require("fs");
const Path = require("path");
const execSync = require("child_process").execSync;
const glob = require("glob").sync;

async function build_crochet_package(file) {
const CrochetForNode = require("./build/targets/node").CrochetForNode;
const pkg = JSON.parse(FS.readFileSync(file, "utf-8"));
console.log(`-> Building ${pkg.name}`);
const crochet = new CrochetForNode(false, [], new Set([]), false);
await crochet.build(file);
}

function copy_tree(from, to, options = {}) {
const skip_special = options.skip_special ?? true;
mkdirp(to);
for (const file of FS.readdirSync(from)) {
if (skip_special && /(^\.)/.test(file)) {
console.log(
`:: Skipping ${Path.join(from, file)} -- not copying special files`
);
continue;
}

const stat = FS.statSync(Path.join(from, file));
if (stat.isFile()) {
FS.copyFileSync(Path.join(from, file), Path.join(to, file));
} else if (stat.isDirectory()) {
copy_tree(Path.join(from, file), Path.join(to, file), options);
} else {
throw new Error(`Unsupported resource type at ${Path.join(from, file)}`);
}
}
}

function mkdirp(path) {
if (!FS.existsSync(path)) {
FS.mkdirSync(path, { recursive: true });
}
}

class World {
constructor() {
Expand Down Expand Up @@ -139,141 +100,6 @@ w.task("benchmark", ["build"], () => {
exec("node --expose-gc build/test/benchmarks/run.js");
}).with_doc("Runs all Crochet benchmarks");

w.task("launcher:build", ["build"], () => {
exec("npm install", { cwd: "tools/launcher" });
exec("npm run build-server", { cwd: "tools/launcher" });
exec("npm run build-app", { cwd: "tools/launcher" });
exec("npm run build-ipc", { cwd: "tools/launcher" });
console.log("-> Copying files to the proper location...");
FS.copyFileSync(
Path.join(__dirname, "www/crochet.js"),
Path.join(__dirname, "tools/launcher/www/crochet.js")
);
copy_tree(
Path.join(__dirname, "tools/launcher/node_modules/monaco-editor/dev"),
Path.join(__dirname, "tools/launcher/www/monaco")
);
}).with_doc("Builds the Crochet IDE");

w.task("launcher:start-server", [], () => {
exec("node build/node-cli.js", { cwd: "tools/launcher" });
}).with_doc("Starts a node server for the IDE");

w.task("launcher:start-gui", [], () => {
exec("npm run start-gui", { cwd: "tools/launcher" });
}).with_doc("Starts an electron app for the IDE");

w.task("launcher:package", [], async () => {
const releases = [
{
name: "win32-x64",
url: "https://github.com/electron/electron/releases/download/v13.6.0/electron-v13.6.0-win32-x64.zip",
zip_name: "electron-v13.6.0-win32-x64.zip",
resource_path: "resources/app",
async rebrand(root) {
FS.renameSync(
Path.join(root, "electron.exe"),
Path.join(root, "crochet.exe")
);
},
},
{
name: "linux-x64",
url: "https://github.com/electron/electron/releases/download/v13.6.0/electron-v13.6.0-linux-x64.zip",
zip_name: "electron-v13.6.0-linux-x64.zip",
resource_path: "resources/app",
async rebrand(root) {
FS.renameSync(Path.join(root, "electron"), Path.join(root, "crochet"));
},
},
];

const pkg = JSON.parse(
FS.readFileSync(Path.join(__dirname, "package.json"), "utf-8")
);
const version = pkg.version;
pkg.main = "tools/launcher/build/electron.js";

console.log("-> Building electron packages for version", version);
const pkg_root = Path.join(__dirname, "dist", version);
const launcher_root = Path.join(__dirname, "tools/launcher");
const repo_root = __dirname;
exec(`rm -rf ${JSON.stringify(pkg_root)}`);
mkdirp(pkg_root);

const app_root = Path.join(pkg_root, "app");
const tool_root = Path.join(app_root, "tools/launcher");
console.log("-> Preparing app...");
mkdirp(app_root);
FS.writeFileSync(
Path.join(app_root, "package.json"),
JSON.stringify(pkg, null, 2)
);
FS.copyFileSync(
Path.join(repo_root, "package-lock.json"),
Path.join(app_root, "package-lock.json")
);
copy_tree(Path.join(repo_root, "build"), Path.join(app_root, "build"));
copy_tree(Path.join(repo_root, "stdlib"), Path.join(app_root, "stdlib"));
copy_tree(Path.join(repo_root, "examples"), Path.join(app_root, "examples"));
copy_tree(Path.join(repo_root, "www"), Path.join(app_root, "www"));

mkdirp(tool_root);
FS.copyFileSync(
Path.join(__dirname, "tools/lingua.js"),
Path.join(app_root, "tools/lingua.js")
);
FS.copyFileSync(
Path.join(launcher_root, "package.json"),
Path.join(tool_root, "package.json")
);
FS.copyFileSync(
Path.join(launcher_root, "package-lock.json"),
Path.join(tool_root, "package-lock.json")
);
copy_tree(Path.join(launcher_root, "www"), Path.join(tool_root, "www"));
copy_tree(Path.join(launcher_root, "build"), Path.join(tool_root, "build"));
copy_tree(Path.join(launcher_root, "app"), Path.join(tool_root, "app"));

console.log("-> Installing dependencies...");
exec("npm install --production", { cwd: app_root });
exec("npm install --production", { cwd: tool_root });

console.log("-> Pre-compiling all Crochet packages...");
const crochet_pkgs = glob("**/crochet.json", {
cwd: app_root,
absolute: true,
});
for (const cpkg of crochet_pkgs) {
await build_crochet_package(cpkg);
}

for (const release of releases) {
const root = Path.join(pkg_root, release.name);

console.log("-> Building", release.name);
mkdirp(root);
exec(`wget ${JSON.stringify(release.url)}`, { cwd: root });
exec(`unzip -q ${JSON.stringify(release.zip_name)}`, { cwd: root });
exec(`rm ${JSON.stringify(release.zip_name)}`, { cwd: root });
console.log("-> Copying files...");
copy_tree(app_root, Path.join(root, release.resource_path), {
skip_special: false,
});
console.log("-> Packaging into a single archive...");
await release.rebrand(root);
exec(
`zip -1 -r -q ${JSON.stringify(
`crochet-${version}-${release.name}.zip`
)} ${JSON.stringify(release.name)}`,
{
cwd: pkg_root,
}
);
console.log(":: Built", release.name, "successfully");
}
}).with_doc("Generates distribution packages for the IDE (Linux only)");

w.task("help", [], () => {
console.log(`Available tasks:\n`);
for (const task of w.all_tasks) {
Expand Down
18 changes: 0 additions & 18 deletions source/node-cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@ interface Options {
package?: string;
show_success: boolean;
};
launcher: {
project_directory: string | null;
};
app_args: string[];
}

Expand All @@ -91,9 +88,6 @@ function parse_options(args0: string[]) {
options.packaging = {
out_dir: "packages",
};
options.launcher = {
project_directory: null,
};
options.docs = {
port: 8080,
target: Crochet.pkg.target_any(),
Expand Down Expand Up @@ -170,12 +164,6 @@ function parse_options(args0: string[]) {
continue;
}

case "--project-directory": {
options.launcher.project_directory = args0[current + 1] ?? null;
current += 2;
continue;
}

case "--capabilities": {
const cap = (args0[current + 1] ?? "").trim().split(/\s*,\s*/);
options.capabilities = new Set(cap);
Expand Down Expand Up @@ -502,7 +490,6 @@ function help(command?: string) {
" crochet repl <crochet.json>\n",
" crochet test <crochet.json> [--test-title PATTERN --test-module PATTERN --test-package PATTERN --test-show-ok]\n",
" crochet build <crochet.json>\n",
" crochet launcher:server <crochet.json> [--project-directory DIR]\n",
" crochet show-ir <file.crochet>\n",
" crochet show-ast <file.crochet>\n",
" crochet new <name>\n",
Expand Down Expand Up @@ -566,11 +553,6 @@ void (async function main() {
return await repl(args, options);
case "new":
return await new_package(args, options);
case "launcher:server": {
const server = require("../../tools/launcher/build/launcher");
await server.start_servers({ ...options.launcher, port: 8000 });
break;
}
case "version": {
const version = require("../../package.json").version;
console.log(`Crochet version ${version}`);
Expand Down
51 changes: 0 additions & 51 deletions tools/launcher/app/crochet.json

This file was deleted.

Loading