Skip to content

Commit

Permalink
chore(js): add core to git
Browse files Browse the repository at this point in the history
  • Loading branch information
tamasfe committed Jun 17, 2022
1 parent 24cb250 commit e62d706
Show file tree
Hide file tree
Showing 11 changed files with 616 additions and 0 deletions.
5 changes: 5 additions & 0 deletions js/core/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
dist
node_modules
target
**/.local*
*.tgz
8 changes: 8 additions & 0 deletions js/core/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
src
target
util
**/.local*
*.tgz
tsconfig.json
rollup.config.js
yarn-error.log
3 changes: 3 additions & 0 deletions js/core/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Core utilities and types for Taplo, not intended for standalone use.

All the documentation and information is available on the [website](https://taplo.tamasfe.dev).
30 changes: 30 additions & 0 deletions js/core/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "@taplo/core",
"version": "0.1.0",
"description": "Commonly used types for Taplo",
"author": {
"name": "tamasfe",
"url": "https://github.com/tamasfe"
},
"scripts": {
"build": "yarn rollup --silent -c rollup.config.js",
"prepack": "yarn build"
},
"types": "dist/index.d.ts",
"main": "dist/index.js",
"license": "MIT",
"autoTag": {
"enabled": true
},
"devDependencies": {
"@rollup/plugin-commonjs": "^22.0.0",
"@rollup/plugin-node-resolve": "^13.3.0",
"@types/node": "^17.0.41",
"esbuild": "^0.14.45",
"rollup": "^2.75.6",
"rollup-plugin-esbuild": "^4.9.1",
"tslib": "^2.4.0",
"typescript": "^4.7.3"
},
"packageManager": "[email protected]"
}
28 changes: 28 additions & 0 deletions js/core/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import resolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import path from "path";
import process from "process";
import { minify } from "rollup-plugin-esbuild";
import typescript from "rollup-plugin-typescript2";

export default {
input: {
index: "src/index.ts",
},
output: {
sourcemap: false,
name: "taploCore",
format: "umd",
dir: "dist",
},
plugins: [
typescript(),
commonjs(),
resolve({
jsnext: true,
preferBuiltins: true,
rootDir: path.join(process.cwd(), ".."),
}),
minify(),
],
};
127 changes: 127 additions & 0 deletions js/core/src/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
import { FormatterOptions } from "./formatter";

export interface Config {
/**
* Files to exclude (ignore).
*
* A list of Unix-like [glob](https://en.wikipedia.org/wiki/Glob_(programming)) path patterns. Globstars (`**`) are supported.
*
* Relative paths are **not** relative to the configuration file, but rather depends on the tool using the configuration.
*
* This has priority over `include`.
*/
exclude?: string[];
/**
* Formatting options.
*/
formatting?: FormatterOptions;
/**
* Files to include.
*
* A list of Unix-like [glob](https://en.wikipedia.org/wiki/Glob_(programming)) path patterns. Globstars (`**`) are supported.
*
* Relative paths are **not** relative to the configuration file, but rather depends on the tool using the configuration.
*
* Omitting this property includes all files, **however an empty array will include none**.
*/
include?: string[];
/**
* Rules are used to override configurations by path and keys.
*/
rule?: Rule[];
/**
* Schema validation options.
*/
schema?: SchemaOptions;
}

/**
* A plugin to extend Taplo's capabilities.
*/
export interface Plugin {
/**
* Optional settings for the plugin.
*/
settings?: {
[k: string]: unknown;
};
[k: string]: unknown;
}
/**
* A rule to override options by either name or file.
*/
export interface Rule {
/**
* Files that are excluded from this rule.
*
* A list of Unix-like [glob](https://en.wikipedia.org/wiki/Glob_(programming)) path patterns.
*
* Relative paths are **not** relative to the configuration file, but rather depends on the tool using the configuration.
*
* This has priority over `include`.
*/
exclude?: string[];
/**
* Formatting options.
*/
formatting?: FormatterOptions;
/**
* Files this rule is valid for.
*
* A list of Unix-like [glob](https://en.wikipedia.org/wiki/Glob_(programming)) path patterns.
*
* Relative paths are **not** relative to the configuration file, but rather depends on the tool using the configuration.
*
* Omitting this property includes all files, **however an empty array will include none**.
*/
include?: string[];
/**
* Keys the rule is valid for in a document.
*
* A list of Unix-like [glob](https://en.wikipedia.org/wiki/Glob_(programming)) dotted key patterns.
*
* This allows enabling the rule for specific paths in the document.
*
* For example:
*
* - `package.metadata` will enable the rule for everything inside the `package.metadata` table, including itself.
*
* If omitted, the rule will always be valid for all keys.
*/
keys?: string[];
/**
* The name of the rule.
*
* Used in `taplo::<name>` comments.
*/
name?: string;
/**
* Schema validation options.
*/
schema?: SchemaOptions;
}
/**
* Options for schema validation and completion.
*
* Schemas in rules with defined keys are ignored.
*/
export interface SchemaOptions {
/**
* Whether the schema should be enabled or not.
*
* Defaults to true if omitted.
*/
enabled?: boolean;
/**
* A local file path to the schema, overrides `url` if set.
*
* For URLs, please use `url` instead.
*/
path?: string;
/**
* A full absolute Url to the schema.
*
* The url of the schema, supported schemes are `http`, `https`, `file` and `taplo`.
*/
url?: string;
}
Loading

0 comments on commit e62d706

Please sign in to comment.