Skip to content

Commit

Permalink
Run typecheck and eslint on Lint CI
Browse files Browse the repository at this point in the history
  • Loading branch information
somebody1234 committed May 8, 2023
1 parent b315b8d commit afbe58a
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 7 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions app/ide-desktop/lib/client/src/file-associations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export function isFileOpenable(path: string): boolean {
* we manually start a new instance of the application and pass the file path to it (using the
* Windows-style command).
*/
export function onFileOpened(event: Event, path: string): string | void {
export function onFileOpened(event: Event, path: string): string | null {
logger.log(`Received 'open-file' event for path '${path}'.`)
if (isFileOpenable(path)) {
logger.log(`The file '${path}' is openable.`)
Expand All @@ -114,7 +114,6 @@ export function onFileOpened(event: Event, path: string): string | void {
if (!electron.app.isReady() && CLIENT_ARGUMENTS.length === 0) {
event.preventDefault()
logger.log(`Opening file '${path}'.`)
// eslint-disable-next-line no-restricted-syntax
return handleOpenFile(path)
} else {
// We need to start another copy of the application, as the first one is already running.
Expand All @@ -128,9 +127,11 @@ export function onFileOpened(event: Event, path: string): string | void {
})
// Prevent parent (this) process from waiting for the child to exit.
child.unref()
return null
}
} else {
logger.log(`The file '${path}' is not openable, ignoring the 'open-file' event.`)
return null
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/ide-desktop/lib/content-config/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import * as semver from 'semver'

import * as linkedDist from '../../../../../target/ensogl-pack/linked-dist/index'
import * as linkedDist from '../../../../../target/ensogl-pack/linked-dist'
import BUILD_INFO from '../../../build.json' assert { type: 'json' }

// Aliases with the same name as the original.
Expand Down
2 changes: 1 addition & 1 deletion app/ide-desktop/lib/content/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import * as semver from 'semver'
import * as authentication from 'enso-authentication'
import * as contentConfig from 'enso-content-config'

import * as app from '../../../../../target/ensogl-pack/linked-dist/index'
import * as app from '../../../../../target/ensogl-pack/linked-dist'
import GLOBAL_CONFIG from '../../../../gui/config.yaml' assert { type: 'yaml' }

const logger = app.log.logger
Expand Down
13 changes: 13 additions & 0 deletions app/ide-desktop/lib/types/modules.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@
*
* This file MUST NOT `export {}` for the modules to be visible to other files. */

// Required because this is a build artifact, which does not exist on a clean repository.
declare module '*/build.json' {
interface BuildInfo {
commit: string
version: string
engineVersion: string
name: string
}

const BUILD_INFO: BuildInfo
export default BUILD_INFO
}

declare module '*/gui/config.yaml' {
interface Config {
windowAppScopeName: string
Expand Down
6 changes: 6 additions & 0 deletions build/ci_utils/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@ pub fn remove_symlink_dir_if_exists(path: impl AsRef<Path>) -> Result {
}
}

/// Create a symlink, or remove and recreate it if it already exists.
pub fn create_or_update_symlink(src: impl AsRef<Path>, dst: impl AsRef<Path>) -> Result {
remove_symlink_dir_if_exists(&dst)?;
symlink_auto(&src, &dst)
}

/// `fs_extra`'s error type is not friendly to `anyhow`, so we need to convert it manually.
///
/// Otherwise, we get just the message to look into the error kind, but the kind information is
Expand Down
1 change: 1 addition & 0 deletions build/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ derivative = { workspace = true }
enso-build-base = { path = "../base" }
enso-build = { path = "../build" }
enso-formatter = { path = "../enso-formatter" }
ensogl-pack = { path = "../../lib/rust/ensogl/pack" }
futures = { workspace = true }
futures-util = "0.3.17"
glob = "0.3.0"
Expand Down
13 changes: 13 additions & 0 deletions build/cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ use ide_ci::programs::git;
use ide_ci::programs::git::clean;
use ide_ci::programs::rustc;
use ide_ci::programs::Cargo;
use ide_ci::programs::Npm;
use ide_ci::programs::Npx;
use std::time::Duration;
use tempfile::tempdir;
use tokio::process::Child;
Expand Down Expand Up @@ -834,7 +836,18 @@ pub async fn main_internal(config: Option<enso_build::config::Config>) -> Result
.run_ok()
.await?;

// Copied from `build` in `lib/rust/ensogl/pack/src/lib.rs`.
let paths = ensogl_pack::Paths::new().await?;
ensogl_pack::compile_this_crate_ts_sources(&paths).await?;
ide_ci::fs::create_or_update_symlink(
&paths.target.ensogl_pack.dist,
&paths.target.ensogl_pack.linked_dist,
)?;
prettier::check(&ctx.repo_root).await?;
let js_modules_root = ctx.repo_root.join("app/ide-desktop");
Npm.cmd()?.current_dir(&js_modules_root).args(["install"]).run_ok().await?;
Npm.cmd()?.current_dir(&js_modules_root).args(["run", "typecheck"]).run_ok().await?;
Npx.cmd()?.current_dir(&js_modules_root).args(["eslint", "."]).run_ok().await?;
}
Target::Fmt => {
let prettier = prettier::write(&ctx.repo_root);
Expand Down
8 changes: 5 additions & 3 deletions lib/rust/ensogl/pack/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ fn check_if_ts_needs_rebuild(paths: &Paths) -> Result<bool> {
}

/// Compile TypeScript sources of this crate in case they were not compiled yet.
async fn compile_this_crate_ts_sources(paths: &Paths) -> Result<()> {
pub async fn compile_this_crate_ts_sources(paths: &Paths) -> Result<()> {
println!("compile_this_crate_ts_sources");
if check_if_ts_needs_rebuild(paths)? {
info!("EnsoGL Pack TypeScript sources changed, recompiling.");
Expand Down Expand Up @@ -464,6 +464,8 @@ pub async fn build(
assets::build(&paths).await?;
let out_dir = Path::new(&outputs.out_dir);
ide_ci::fs::copy(&paths.target.ensogl_pack.dist, out_dir)?;
ide_ci::fs::remove_symlink_dir_if_exists(&paths.target.ensogl_pack.linked_dist)?;
ide_ci::fs::symlink_auto(&paths.target.ensogl_pack.dist, &paths.target.ensogl_pack.linked_dist)
ide_ci::fs::create_or_update_symlink(
&paths.target.ensogl_pack.dist,
&paths.target.ensogl_pack.linked_dist,
)
}

0 comments on commit afbe58a

Please sign in to comment.