From d2a70667fca53f6448143d17e2b38265ffcf92ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20Dani=C5=82o?= Date: Thu, 5 Mar 2020 20:00:47 +0100 Subject: [PATCH] Cleaning codebase (https://github.com/enso-org/ide/pull/235) Original commit: https://github.com/enso-org/ide/commit/820113e0612cfdba03ff485a0849a47189ff5845 --- gui/.gitignore | 3 - gui/.nvmrc | 1 - gui/Cargo.toml | 2 +- gui/app/package-lock.json | 70 +++++++++---------- gui/build/run.js | 47 +++++++------ gui/build/rust/src/bin/test-all.rs | 2 +- .../utilities}/Cargo.toml | 0 .../utilities}/src/lib.rs | 6 +- gui/docs/contributing.md | 3 +- gui/lib/core/embedded-fonts/Cargo.toml | 2 +- gui/lib/core/msdf-sys/Cargo.toml | 4 +- gui/lib/ide/Cargo.toml | 2 +- gui/lib/ide/parser/Cargo.toml | 2 +- gui/run | 7 +- 14 files changed, 75 insertions(+), 76 deletions(-) delete mode 100644 gui/.nvmrc rename gui/{build-utilities => build/utilities}/Cargo.toml (100%) rename gui/{build-utilities => build/utilities}/src/lib.rs (92%) diff --git a/gui/.gitignore b/gui/.gitignore index 58059b8e68..54718befd3 100644 --- a/gui/.gitignore +++ b/gui/.gitignore @@ -17,6 +17,3 @@ wasm-pack.log # JavaScript node_modules - -# Markers -.initialized diff --git a/gui/.nvmrc b/gui/.nvmrc deleted file mode 100644 index b009dfb9d9..0000000000 --- a/gui/.nvmrc +++ /dev/null @@ -1 +0,0 @@ -lts/* diff --git a/gui/Cargo.toml b/gui/Cargo.toml index 3022d6797b..ea742d0676 100644 --- a/gui/Cargo.toml +++ b/gui/Cargo.toml @@ -1,7 +1,7 @@ [workspace] members = [ - "build-utilities", + "build/utilities", "lib/code-builder", "lib/core", "lib/core/embedded-fonts", diff --git a/gui/app/package-lock.json b/gui/app/package-lock.json index 8d663d5f43..818a69ead1 100644 --- a/gui/app/package-lock.json +++ b/gui/app/package-lock.json @@ -1594,25 +1594,25 @@ } }, "app-builder-bin": { - "version": "3.5.4", - "resolved": "https://registry.npmjs.org/app-builder-bin/-/app-builder-bin-3.5.4.tgz", - "integrity": "sha512-Bta3I+OU64ePwvSdhpYyCj11XcR8VGdlPSINM87LPg0apCbprLu03zvnmnHRw/RvZB2RGAQ93Z8NO3JT3DbXdA==" + "version": "3.5.5", + "resolved": "https://registry.npmjs.org/app-builder-bin/-/app-builder-bin-3.5.5.tgz", + "integrity": "sha512-ZcHzJ9Xl+azPqdKzXZKdRZmkNmbxHHZyl4cbobNf8qMQpoPChpcov8riVrZSbu/0cT/JqJ8LOwJjy1OAwbChaQ==" }, "app-builder-lib": { - "version": "22.3.6", - "resolved": "https://registry.npmjs.org/app-builder-lib/-/app-builder-lib-22.3.6.tgz", - "integrity": "sha512-9TANMAFL7cFNuRB3cMc1BS5dBQzqY5RVEUD4VMZ0MYhFY/DM9+v2BvfY3Ef+7XSOzirA6p4TljAVz5ydIEdZFw==", + "version": "22.4.0", + "resolved": "https://registry.npmjs.org/app-builder-lib/-/app-builder-lib-22.4.0.tgz", + "integrity": "sha512-PcoKR5EDc6hkjNA7RzE0Ery1w1+YOH2VPk9AGQWAvQluj5h6xcURMQilLhQYONNZ3N/beZmiNxPzQF0CBRCnwA==", "requires": { "7zip-bin": "~5.0.3", "@develar/schema-utils": "~2.1.0", "async-exit-hook": "^2.0.1", "bluebird-lst": "^1.0.9", - "builder-util": "22.3.6", + "builder-util": "22.4.0", "builder-util-runtime": "8.6.1", "chromium-pickle-js": "^0.2.0", "debug": "^4.1.1", "ejs": "^3.0.1", - "electron-publish": "22.3.6", + "electron-publish": "22.4.0", "fs-extra": "^8.1.0", "hosted-git-info": "^3.0.4", "is-ci": "^2.0.0", @@ -1967,11 +1967,11 @@ } }, "bl": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/bl/-/bl-3.0.0.tgz", - "integrity": "sha512-EUAyP5UHU5hxF8BPT0LKW8gjYLhq1DQIcneOX/pL/m2Alo+OYDQAJlHq+yseMP50Os2nHXOSic6Ss3vSQeyf4A==", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/bl/-/bl-4.0.1.tgz", + "integrity": "sha512-FL/TdvchukRCuWVxT0YMO/7+L5TNeNrVFvRU2IY63aUyv9mpt8splf2NEr6qXtPo5fya5a66YohQKvGNmLrWNA==", "requires": { - "readable-stream": "^3.0.1" + "readable-stream": "^3.4.0" }, "dependencies": { "readable-stream": { @@ -2350,14 +2350,14 @@ "dev": true }, "builder-util": { - "version": "22.3.6", - "resolved": "https://registry.npmjs.org/builder-util/-/builder-util-22.3.6.tgz", - "integrity": "sha512-1fMRRouGzggUcPcy/ZR2NV8KZejwXPYNRD4vr/Ws/KvGQFNMTHA9VFscT7tGfOseQCLaLsa5C2gU5MOAiFx7AA==", + "version": "22.4.0", + "resolved": "https://registry.npmjs.org/builder-util/-/builder-util-22.4.0.tgz", + "integrity": "sha512-U2mNL9IewgTqfhvNexrm3UFdRrI6Rr48HkH9Z0IO/D86jGrCUVK8UXC8S8AHj1Cfa/VdYrMOxdXr3kajZXJvfg==", "requires": { "7zip-bin": "~5.0.3", "@types/debug": "^4.1.5", "@types/fs-extra": "^8.1.0", - "app-builder-bin": "3.5.4", + "app-builder-bin": "3.5.5", "bluebird-lst": "^1.0.9", "builder-util-runtime": "8.6.1", "chalk": "^3.0.0", @@ -3961,13 +3961,13 @@ } }, "dmg-builder": { - "version": "22.3.6", - "resolved": "https://registry.npmjs.org/dmg-builder/-/dmg-builder-22.3.6.tgz", - "integrity": "sha512-pUrvvzkSZfaCIXofqNH+YJ0ajgi4DDe/ZjMiL/T1yKrRXK3v7sfmnbSzHY8V/WtimSgzsK1izFg/SBsfwFsZWw==", + "version": "22.4.0", + "resolved": "https://registry.npmjs.org/dmg-builder/-/dmg-builder-22.4.0.tgz", + "integrity": "sha512-tQvHhI2PZi4mn2CqzLyWohbipwrFJ5Wz97shsnzgje4uvVTnScF5nimoKCfnNIX5pcKL17Ij7f8WpluqeRDBTg==", "requires": { - "app-builder-lib": "~22.3.6", + "app-builder-lib": "~22.4.0", "bluebird-lst": "^1.0.9", - "builder-util": "~22.3.6", + "builder-util": "~22.4.0", "fs-extra": "^8.1.0", "iconv-lite": "^0.5.1", "js-yaml": "^3.13.1", @@ -4099,17 +4099,17 @@ } }, "electron-builder": { - "version": "22.3.6", - "resolved": "https://registry.npmjs.org/electron-builder/-/electron-builder-22.3.6.tgz", - "integrity": "sha512-W1fMEtAT7WOqetwTR2uCesMIqmnr8DHR9ZKYlHMxGxQt0jGaBX/gQHPf6+R8d2SQq2Bup6e1eE0xoeX3ixCfTw==", + "version": "22.4.0", + "resolved": "https://registry.npmjs.org/electron-builder/-/electron-builder-22.4.0.tgz", + "integrity": "sha512-6gmXgtkc3DHN+qqTdpFrE340BvzYOLrYQnvVX8Dpz+FLBIj6kg9eH4/MVDrqRjeW8F6DsIZ3jnlM91cWiE5r0g==", "requires": { "@types/yargs": "^15.0.4", - "app-builder-lib": "22.3.6", + "app-builder-lib": "22.4.0", "bluebird-lst": "^1.0.9", - "builder-util": "22.3.6", + "builder-util": "22.4.0", "builder-util-runtime": "8.6.1", "chalk": "^3.0.0", - "dmg-builder": "22.3.6", + "dmg-builder": "22.4.0", "fs-extra": "^8.1.0", "is-ci": "^2.0.0", "lazy-val": "^1.0.4", @@ -4281,13 +4281,13 @@ "integrity": "sha512-Z1qA/1oHNowGtSBIcWk0pcLEqYT/j+13xUw/MYOrBUOL4X7VN0i0KCTf5SqyvMPmW5pSPKbo28wkxMxzZ20YnQ==" }, "electron-publish": { - "version": "22.3.6", - "resolved": "https://registry.npmjs.org/electron-publish/-/electron-publish-22.3.6.tgz", - "integrity": "sha512-u4PW4ec4rPcdFUVMvL5OrqoYX8WLJHab8DtPkh/oZ2HPzGGX3eWnUvulIIJ4SUnesSYkbUcZd1RDYtfV52Q72w==", + "version": "22.4.0", + "resolved": "https://registry.npmjs.org/electron-publish/-/electron-publish-22.4.0.tgz", + "integrity": "sha512-50p+H/FsgwvOgLP8Oekvar07MR70M+cYROlH3ty5bIq0io6doEVPl+j/Cc8tfN/tygZecBKUCdYJMXjILQPn+A==", "requires": { "@types/fs-extra": "^8.1.0", "bluebird-lst": "^1.0.9", - "builder-util": "~22.3.6", + "builder-util": "~22.4.0", "builder-util-runtime": "8.6.1", "chalk": "^3.0.0", "fs-extra": "^8.1.0", @@ -10768,11 +10768,11 @@ } }, "tar-stream": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.1.0.tgz", - "integrity": "sha512-+DAn4Nb4+gz6WZigRzKEZl1QuJVOLtAwwF+WUxy1fJ6X63CaGaUAxJRD2KEn1OMfcbCjySTYpNC6WmfQoIEOdw==", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.1.1.tgz", + "integrity": "sha512-GZjLk64XcE/58qwIc1ZfXGqTSE4OutPMEkfBE/oh9eJ4x1eMRjYkgrLrav7PzddpvIpSJSGi8FgNNYXdB9Vumg==", "requires": { - "bl": "^3.0.0", + "bl": "^4.0.1", "end-of-stream": "^1.4.1", "fs-constants": "^1.0.0", "inherits": "^2.0.3", diff --git a/gui/build/run.js b/gui/build/run.js index dfa06e3e86..e9e441f92b 100755 --- a/gui/build/run.js +++ b/gui/build/run.js @@ -22,19 +22,17 @@ Usage: run command [options] Please note that all arguments after '--' will be passed to sub-commands. Commands: - help Print this help message. - clean Clean all build artifacts. - check Fast check if project builds (only Rust target). - build Build the sources. - dist Build the sources and create distribution packages. - watch Start a file-watch utility and run interactive mode. + help Print this help message. + clean Clean all build artifacts. + check Fast check if project builds (only Rust target). + build Build the sources. + dist Build the sources and create distribution packages. + watch Start a file-watch utility and run interactive mode. Options: - --help Print this help message - --only-rust Run the Rust target only. - --only-js Run the js target only. - --no-rust Do not run the Rust target. - --no-js Do not run the JavaScript target. + --help Print this help message + --js Run the JavaScript target [true]. + --rust Run the Rust target [true]. ` function print_help () { @@ -44,7 +42,7 @@ function print_help () { function validate_options() { let args_check = Object.assign({},argv) - for (arg of ['_','--','validation','help','only-rust','only-js','rust','js']) { + for (arg of ['_','--','validation','help','rust','js']) { delete args_check[arg] } @@ -72,6 +70,11 @@ async function copy(src,tgt) { }) } +/// Run the command with the provided args and all args passed to this script after the `--` symbol. +async function run(command,args) { + await cmd.run(command,args.concat(child_argv)) +} + // ============= @@ -80,14 +83,14 @@ async function copy(src,tgt) { async function clean_js () { await cmd.with_cwd('app', async () => { - await cmd.run('npm',['run','clean'].concat(child_argv)) + await run('npm',['run','clean']) }) try { await fs.unlink('.initialized') } catch {} } async function clean_rust () { try { await fs.rmdir('app/generated') } catch {} - // TODO finish + await run('cargo',['clean']) } @@ -97,7 +100,7 @@ async function clean_rust () { // ============= async function check_rust() { - await cmd.run('cargo',['check'].concat(child_argv)) + await run('cargo',['check']) } async function check_js() {} @@ -111,13 +114,13 @@ async function check_js() {} async function build_js () { console.log(`Building JS target.`) await cmd.with_cwd('app', async () => { - await cmd.run('npm',['run','build'].concat(child_argv)) + await run('npm',['run','build']) }) } async function build_rust () { console.log(`Building WASM target.`) - await cmd.run('wasm-pack',['build','--target','web','--no-typescript','--out-dir','../../target/web','lib/gui'].concat(child_argv)) + await run('wasm-pack',['build','--target','web','--no-typescript','--out-dir','../../target/web','lib/gui']) await patch_file('target/web/gui.js', js_workaround_patcher) await fs.rename('target/web/gui_bg.wasm','target/web/gui.wasm') @@ -151,7 +154,7 @@ async function patch_file(path,patcher) { // ============ async function lint_rust() { - await cmd.run('cargo',['clippy','--','-D','warnings'].concat(child_argv)) + await run('cargo',['clippy','--','-D','warnings']) } async function lint_js() {} @@ -170,7 +173,7 @@ async function watch_rust () { async function watch_js () { await cmd.with_cwd('app', async () => { - await cmd.run('npm',['run','watch'].concat(child_argv)) + await run('npm',['run','watch']) }) } @@ -186,7 +189,7 @@ async function dist_rust () { async function dist_js () { await cmd.with_cwd('app', async () => { - await cmd.run('npm',['run','dist'].concat(child_argv)) + await run('npm',['run','dist']) }) } @@ -199,8 +202,8 @@ async function dist_js () { async function main () { let command = argv._[0] - let do_rust = ((argv.rust) || (argv.rust == undefined)) && (!argv['only-js']) - let do_js = ((argv.js) || (argv.js == undefined)) && (!argv['only-rust']) + let do_rust = (argv.rust == true) || (argv.rust == undefined) + let do_js = (argv.js == true) || (argv.js == undefined) if (command == 'clean') { cmd.section('Cleaning') diff --git a/gui/build/rust/src/bin/test-all.rs b/gui/build/rust/src/bin/test-all.rs index c0ccd77ece..2e9e18bc45 100644 --- a/gui/build/rust/src/bin/test-all.rs +++ b/gui/build/rust/src/bin/test-all.rs @@ -6,7 +6,7 @@ use std::path::Path; /// List of workspace members that should not be tested by wasm-pack test. /// (e.g. because they do not target wasm at all) const PACKAGE_BLACKLIST:[&str;2] = [ - "build-utilities", + "build/utilities", "lib/ide/file-manager/mock-server" ]; diff --git a/gui/build-utilities/Cargo.toml b/gui/build/utilities/Cargo.toml similarity index 100% rename from gui/build-utilities/Cargo.toml rename to gui/build/utilities/Cargo.toml diff --git a/gui/build-utilities/src/lib.rs b/gui/build/utilities/src/lib.rs similarity index 92% rename from gui/build-utilities/src/lib.rs rename to gui/build/utilities/src/lib.rs index b5041863e8..6188406b8a 100644 --- a/gui/build-utilities/src/lib.rs +++ b/gui/build/utilities/src/lib.rs @@ -7,7 +7,7 @@ use std::io::ErrorKind; /// Types that can yield a reference to std::path::Path. pub trait PathRef = AsRef; -/// A structure describing a concrete release package on github. +/// A structure describing a concrete release package on GitHub. pub struct GithubRelease { pub project_url : Str, pub version : Str, @@ -15,9 +15,9 @@ pub struct GithubRelease { } impl GithubRelease { - /// Download the release package from github + /// Download the release package from GitHub. /// - /// The project_url should be a project's main page on github. + /// The project_url should be a project's main page on GitHub. pub fn download(&self, destination_dir:&path::Path) where Str:AsRef { let url = format!( "{project}/releases/download/{version}/{filename}", diff --git a/gui/docs/contributing.md b/gui/docs/contributing.md index b4360a6ce5..d420ceb21d 100644 --- a/gui/docs/contributing.md +++ b/gui/docs/contributing.md @@ -22,8 +22,7 @@ need the following setup: changes are known to cause serious issues, thus **we provide support for the latest LTS version only. Please do not report build issues if you use other versions.** In case you run run MacOS or Linux the easiest way to setup the proper version is by installing the - [Node Version Manager](https://github.com/nvm-sh/nvm) and running `nvm use` in the root of - this codebase. + [Node Version Manager](https://github.com/nvm-sh/nvm) and running `nvm use --lts`.

diff --git a/gui/lib/core/embedded-fonts/Cargo.toml b/gui/lib/core/embedded-fonts/Cargo.toml index d4d8c808ae..d0326391db 100644 --- a/gui/lib/core/embedded-fonts/Cargo.toml +++ b/gui/lib/core/embedded-fonts/Cargo.toml @@ -13,5 +13,5 @@ crate-type = ["cdylib", "rlib"] enso-prelude = { version = "0.1.0", path="../../prelude"} [build-dependencies] -basegl-build-utilities = { version = "0.1.0", path="../../../build-utilities" } +basegl-build-utilities = { version = "0.1.0", path="../../../build/utilities" } zip = "0.5" diff --git a/gui/lib/core/msdf-sys/Cargo.toml b/gui/lib/core/msdf-sys/Cargo.toml index ff124d574a..c8630b4efd 100644 --- a/gui/lib/core/msdf-sys/Cargo.toml +++ b/gui/lib/core/msdf-sys/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" crate-type = ["cdylib", "rlib"] [dependencies] -wasm-bindgen = { version = "=0.2.58" } +wasm-bindgen = { version = "=0.2.58" } js-sys = { version = "0.3.30" } nalgebra = { version = "0.19.0" } enso-prelude = { version = "0.1.0", path="../../prelude" } @@ -19,4 +19,4 @@ futures = { version = "0.3.1" } basegl-core-embedded-fonts = { version = "0.1.0", path="../embedded-fonts" } [build-dependencies] -basegl-build-utilities = { version = "0.1.0", path="../../../build-utilities" } \ No newline at end of file +basegl-build-utilities = { version = "0.1.0", path="../../../build/utilities" } \ No newline at end of file diff --git a/gui/lib/ide/Cargo.toml b/gui/lib/ide/Cargo.toml index 5d9b33e9fd..12f6f0e873 100644 --- a/gui/lib/ide/Cargo.toml +++ b/gui/lib/ide/Cargo.toml @@ -30,7 +30,7 @@ js-sys = { version = "0.3.35" } serde = { version = "1.0", features = ["derive"] } serde_json = { version = "1.0" } uuid = { version = "0.8", features = ["serde", "v5"] } -wasm-bindgen = { version = "=0.2.58" } +wasm-bindgen = { version = "=0.2.58" } wasm-bindgen-test = { version = "0.3.8" } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] diff --git a/gui/lib/ide/parser/Cargo.toml b/gui/lib/ide/parser/Cargo.toml index 058defb712..84fe06c998 100644 --- a/gui/lib/ide/parser/Cargo.toml +++ b/gui/lib/ide/parser/Cargo.toml @@ -26,7 +26,7 @@ wasm-bindgen = { version = "=0.2.58" wasm-bindgen-test = { version = "0.3.8" } [build-dependencies] -basegl-build-utilities = { version = "0.1.0", path = "../../../build-utilities" } +basegl-build-utilities = { version = "0.1.0", path = "../../../build/utilities" } bytes = { version = "0.5.4" } futures = { version = "0.3.1" } reqwest = { version = "0.10.1" } diff --git a/gui/run b/gui/run index a6f97625a4..e25b301a99 100755 --- a/gui/run +++ b/gui/run @@ -13,7 +13,7 @@ async function init () { await cmd.check_version('rustc','1.40.0-nightly',{preprocess:(v)=>v.substring(6,20),silent:true}) } - let initialized = fss.existsSync('.initialized') + let initialized = fss.existsSync('target/.initialized') if (!initialized) { cmd.section('Initialization') console.log('Installing build script dependencies.') @@ -22,13 +22,14 @@ async function init () { }) if(args[0] == 'clean') { - console.log('Skipping full initialization.') + try { await fs.unlink('target/.initialized') } catch {} } else { console.log('Installing application dependencies') await cmd.with_cwd('app', async () => { await cmd.run('npm',['run','install']) }) - await fs.open('.initialized','w') + await fs.mkdir('target', {recursive:true}) + await fs.open('target/.initialized','w') } } }