Skip to content

Commit

Permalink
[WIP] output formatting (mis)matches
Browse files Browse the repository at this point in the history
  • Loading branch information
JamieMason committed Oct 9, 2024
1 parent e57dbd6 commit b026772
Show file tree
Hide file tree
Showing 9 changed files with 321 additions and 233 deletions.
Original file line number Diff line number Diff line change
@@ -1,120 +1,120 @@
{
"name": "@fluid-experimental/property-binder",
"version": "2.2.0-rc.1.1.2",
"description": "Data Binder for Fluid PropertyDDS",
"keywords": [],
"homepage": "https://fluidframework.com",
"repository": {
"type": "git",
"url": "https://github.com/microsoft/FluidFramework.git",
"directory": "experimental/PropertyDDS/packages/property-binder"
},
"license": "MIT",
"author": "Microsoft and contributors",
"type": "module",
"exports": {
".": {
"import": {
"types": "./lib/index.d.ts",
"default": "./lib/index.js"
},
"require": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
}
},
"main": "lib/index.js",
"types": "lib/index.d.ts",
"files": [
"dist/**/*",
"lib/**/*",
"dist/index.d.ts"
],
"scripts": {
"build": "fluid-build . --task build",
"postbuild": "npm run gen:tscdef",
"build:commonjs": "fluid-build . --task commonjs",
"build:compile": "fluid-build . --task compile",
"build:esnext": "tsc --project ./tsconfig.json",
"build:test": "npm run build:test:cjs",
"build:test:cjs": "fluid-tsc commonjs --project ./src/test/tsconfig.json",
"check:are-the-types-wrong": "attw --pack .",
"check:prettier": "prettier --check . --cache --ignore-path ../../../../.prettierignore",
"clean": "rimraf --glob dist lib \"**/*.tsbuildinfo\" \"**/*.build.log\" nyc",
"doc": "cross-var appfw-typedoc $npm_package_name",
"eslint": "eslint --format stylish src",
"eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
"format": "fluid-build --task format .",
"format:prettier": "prettier --write . --cache --ignore-path ../../../../.prettierignore",
"lint": "fluid-build . --task lint",
"lint:fix": "fluid-build . --task eslint:fix --task format",
"precit": "bash -c \"npm run test -- --reporters dots; echo '----------Linting----------'; npm run lint; echo '----------Docs----------'; npm run doc\"",
"prepublishOnly": "npm run test:dist",
"test": "npm run test:jest",
"pretest:coverage": "rimraf --glob coverage/",
"test:coverage": "c8 npm test",
"test:jest": "jest",
"tsc": "fluid-tsc commonjs --project ./tsconfig.cjs.json && copyfiles -f ../../../../common/build/build-common/src/cjs/package.json ./dist"
},
"c8": {
"all": true,
"cache-dir": "nyc/.cache",
"exclude": [
"src/test/**/*.*ts",
"dist/test/**/*.*js"
],
"exclude-after-remap": false,
"include": [
"src/**/*.*ts",
"dist/**/*.*js"
],
"report-dir": "nyc/report",
"reporter": [
"cobertura",
"html",
"text"
],
"temp-directory": "nyc/.nyc_output"
},
"dependencies": {
"@fluid-experimental/property-changeset": "workspace:~",
"@fluid-experimental/property-dds": "workspace:~",
"@fluid-experimental/property-properties": "workspace:~",
"lodash": "^4.1.0",
"underscore": "^1.2.1"
},
"devDependencies": {
"@arethetypeswrong/cli": "^0.1.0",
"@babel/core": "^7.1.0",
"@babel/eslint-parser": "^7.1.1",
"@babel/plugin-proposal-decorators": "^7.1.1",
"@biomejs/biome": "^1.1.1",
"@fluidframework/build-common": "^2.0.1",
"@fluidframework/build-tools": "^0.1.1",
"@fluidframework/test-runtime-utils": "workspace:~",
"@types/jest": "29.0.1",
"@types/lodash": "^4.1.0",
"@types/node": "^18.0.2",
"@types/underscore": "^1.0.1",
"async": "^3.2.2",
"body-parser": "^1.1.1",
"c8": "^8.2.1",
"chai": "^4.0.0",
"copyfiles": "^2.0.1",
"eslint": "~8.1.0",
"jest": "^29.1.1",
"jest-junit": "^10.1.2",
"jsdoc": "3.1.2",
"prettier": "~3.1.1",
"rimraf": "^4.1.1",
"source-map-loader": "^2.1.1",
"typedoc": "^0.1.1",
"typescript": "~5.1.2",
"webpack": "^5.1.1"
},
"typeValidation": {
"disabled": true,
"broken": {}
}
"name": "@fluid-experimental/property-binder",
"description": "Data Binder for Fluid PropertyDDS",
"version": "2.2.0-rc.1.1.2",
"author": "Microsoft and contributors",
"c8": {
"all": true,
"cache-dir": "nyc/.cache",
"exclude": [
"src/test/**/*.*ts",
"dist/test/**/*.*js"
],
"exclude-after-remap": false,
"include": [
"src/**/*.*ts",
"dist/**/*.*js"
],
"report-dir": "nyc/report",
"reporter": [
"cobertura",
"html",
"text"
],
"temp-directory": "nyc/.nyc_output"
},
"dependencies": {
"@fluid-experimental/property-changeset": "workspace:~",
"@fluid-experimental/property-dds": "workspace:~",
"@fluid-experimental/property-properties": "workspace:~",
"lodash": "^4.1.0",
"underscore": "^1.2.1"
},
"devDependencies": {
"@arethetypeswrong/cli": "^0.1.0",
"@babel/core": "^7.1.0",
"@babel/eslint-parser": "^7.1.1",
"@babel/plugin-proposal-decorators": "^7.1.1",
"@biomejs/biome": "^1.1.1",
"@fluidframework/build-common": "^2.0.1",
"@fluidframework/build-tools": "^0.1.1",
"@fluidframework/test-runtime-utils": "workspace:~",
"@types/jest": "29.0.1",
"@types/lodash": "^4.1.0",
"@types/node": "^18.0.2",
"@types/underscore": "^1.0.1",
"async": "^3.2.2",
"body-parser": "^1.1.1",
"c8": "^8.2.1",
"chai": "^4.0.0",
"copyfiles": "^2.0.1",
"eslint": "~8.1.0",
"jest": "^29.1.1",
"jest-junit": "^10.1.2",
"jsdoc": "3.1.2",
"prettier": "~3.1.1",
"rimraf": "^4.1.1",
"source-map-loader": "^2.1.1",
"typedoc": "^0.1.1",
"typescript": "~5.1.2",
"webpack": "^5.1.1"
},
"exports": {
".": {
"import": {
"types": "./lib/index.d.ts",
"default": "./lib/index.js"
},
"require": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
}
},
"files": [
"dist/**/*",
"lib/**/*",
"dist/index.d.ts"
],
"homepage": "https://fluidframework.com",
"keywords": [],
"license": "MIT",
"main": "lib/index.js",
"repository": {
"type": "git",
"url": "https://github.com/microsoft/FluidFramework.git",
"directory": "experimental/PropertyDDS/packages/property-binder"
},
"scripts": {
"build": "fluid-build . --task build",
"build:commonjs": "fluid-build . --task commonjs",
"build:compile": "fluid-build . --task compile",
"build:esnext": "tsc --project ./tsconfig.json",
"build:test": "npm run build:test:cjs",
"build:test:cjs": "fluid-tsc commonjs --project ./src/test/tsconfig.json",
"check:are-the-types-wrong": "attw --pack .",
"check:prettier": "prettier --check . --cache --ignore-path ../../../../.prettierignore",
"clean": "rimraf --glob dist lib \"**/*.tsbuildinfo\" \"**/*.build.log\" nyc",
"doc": "cross-var appfw-typedoc $npm_package_name",
"eslint": "eslint --format stylish src",
"eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
"format": "fluid-build --task format .",
"format:prettier": "prettier --write . --cache --ignore-path ../../../../.prettierignore",
"lint": "fluid-build . --task lint",
"lint:fix": "fluid-build . --task eslint:fix --task format",
"postbuild": "npm run gen:tscdef",
"precit": "bash -c \"npm run test -- --reporters dots; echo '----------Linting----------'; npm run lint; echo '----------Docs----------'; npm run doc\"",
"prepublishOnly": "npm run test:dist",
"pretest:coverage": "rimraf --glob coverage/",
"test": "npm run test:jest",
"test:coverage": "c8 npm test",
"test:jest": "jest",
"tsc": "fluid-tsc commonjs --project ./tsconfig.cjs.json && copyfiles -f ../../../../common/build/build-common/src/cjs/package.json ./dist"
},
"type": "module",
"types": "lib/index.d.ts",
"typeValidation": {
"disabled": true,
"broken": {}
}
}
2 changes: 1 addition & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ run-fluid-prod:
# Watch lint output during dev
watch-fluid:
#!/usr/bin/env bash
cargo watch --clear --shell 'cd fixtures/fluid-framework && RUST_BACKTRACE=1 cargo run -- lint --versions'
cargo watch --clear --shell 'cd fixtures/fluid-framework && RUST_BACKTRACE=1 cargo run -- lint --versions --format'
# ==============================================================================
# Build
Expand Down
14 changes: 12 additions & 2 deletions src/context.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
use std::rc::Rc;
use std::{cell::RefCell, collections::HashMap, rc::Rc};

use crate::{config::Config, instance::Instance, packages::Packages, semver_group::SemverGroup, version_group::VersionGroup};
use crate::{
config::Config,
instance::Instance,
package_json::{FormatMismatch, FormatMismatchVariant},
packages::Packages,
semver_group::SemverGroup,
version_group::VersionGroup,
};

#[derive(Debug)]
pub struct Context {
/// All default configuration with user config applied
pub config: Config,
/// The exit code of the program
pub exit_code: i32,
/// All formatting issues in package.json files
pub formatting_mismatches_by_variant: RefCell<HashMap<FormatMismatchVariant, Vec<Rc<FormatMismatch>>>>,
/// Every instance in the project
pub instances: Vec<Rc<Instance>>,
/// Every package.json in the project
Expand Down Expand Up @@ -41,6 +50,7 @@ impl Context {
Self {
config,
exit_code: 0,
formatting_mismatches_by_variant: RefCell::new(HashMap::new()),
instances,
packages,
semver_groups,
Expand Down
45 changes: 24 additions & 21 deletions src/effects/lint.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use colored::*;
use itertools::Itertools;
use log::info;

use crate::{context::Context, effects::ui::Ui, version_group::VersionGroupVariant};
Expand All @@ -7,9 +8,11 @@ use crate::{context::Context, effects::ui::Ui, version_group::VersionGroupVarian
pub fn run(ctx: Context) -> Context {
// @TODO: move values to config file
let ui = Ui {
ctx: &ctx,
show_ignored: true,
show_instances: true,
show_status_codes: true,
show_packages: true,
};

if ctx.config.cli.options.versions {
Expand All @@ -21,49 +24,49 @@ pub fn run(ctx: Context) -> Context {
match dependency.variant {
VersionGroupVariant::Banned => {
ui.print_dependency_header(dependency);
dependency.instances.borrow().iter().for_each(|instance| {
ui.print_instance_link(instance);
});
ui.print_instances(&dependency.instances.borrow());
}
VersionGroupVariant::HighestSemver | VersionGroupVariant::LowestSemver => {
ui.print_dependency_header(dependency);
dependency.instances.borrow().iter().for_each(|instance| {
ui.print_instance_link(instance);
});
ui.print_instances(&dependency.instances.borrow());
}
VersionGroupVariant::Ignored => {
ui.print_dependency_header(dependency);
dependency.instances.borrow().iter().for_each(|instance| {
ui.print_instance_link(instance);
});
ui.print_instances(&dependency.instances.borrow());
}
VersionGroupVariant::Pinned => {
ui.print_dependency_header(dependency);
dependency.instances.borrow().iter().for_each(|instance| {
ui.print_instance_link(instance);
});
ui.print_instances(&dependency.instances.borrow());
}
VersionGroupVariant::SameRange => {
ui.print_dependency_header(dependency);
dependency.instances.borrow().iter().for_each(|instance| {
ui.print_instance_link(instance);
});
ui.print_instances(&dependency.instances.borrow());
}
VersionGroupVariant::SnappedTo => {
ui.print_dependency_header(dependency);
dependency.instances.borrow().iter().for_each(|instance| {
ui.print_instance_link(instance);
});
ui.print_instances(&dependency.instances.borrow());
}
}
});
});
}
if ctx.config.cli.options.format {
info!("{}", "= FORMATTING".dimmed());
ctx.packages.by_name.values().for_each(|package| {
//
});
let formatted_packages = ctx
.packages
.by_name
.values()
.filter(|package| package.borrow().formatting_mismatches.borrow().is_empty())
.sorted_by(|a, b| b.borrow().get_name_unsafe().cmp(&a.borrow().get_name_unsafe()))
.collect_vec();
ui.print_formatted_packages(formatted_packages);
ctx
.formatting_mismatches_by_variant
.borrow()
.iter()
.for_each(|(variant, mismatches)| {
ui.print_formatting_mismatches(variant, mismatches);
});
}
ctx
}
Loading

0 comments on commit b026772

Please sign in to comment.