Rearrange into two packages, using yarn workspaces
This commit is contained in:
parent
8187337187
commit
754306aca3
|
@ -1,4 +1,2 @@
|
|||
dist/
|
||||
lib/
|
||||
yarn-error.log
|
||||
node_modules/
|
||||
package-lock.json
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Use yarn, not npm!
|
|
@ -1,17 +1,6 @@
|
|||
{
|
||||
"name": "preserves",
|
||||
"version": "0.7.0",
|
||||
"description": "Experimental data serialization format",
|
||||
"homepage": "https://gitlab.com/preserves/preserves",
|
||||
"license": "Apache-2.0",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"repository": "gitlab:preserves/preserves",
|
||||
"main": "dist/preserves.js",
|
||||
"module": "lib/index.js",
|
||||
"types": "lib/index.d.ts",
|
||||
"author": "Tony Garnock-Jones <tonyg@leastfixedpoint.com>",
|
||||
"name": "@preserves/root",
|
||||
"private": true,
|
||||
"devDependencies": {
|
||||
"@types/jest": "^26.0.19",
|
||||
"jest": "^26.6.3",
|
||||
|
@ -21,17 +10,15 @@
|
|||
"ts-node-dev": "^1.1.6",
|
||||
"typescript": "^4.2.2"
|
||||
},
|
||||
"workspaces": [
|
||||
"packages/*"
|
||||
],
|
||||
"scripts": {
|
||||
"clean": "rm -rf lib dist",
|
||||
"prepare": "npx tsc && npx rollup -c",
|
||||
"rollupwatch": "npx rollup -c -w",
|
||||
"test": "npx jest",
|
||||
"testwatch": "npx jest --watch",
|
||||
"veryclean": "npm run clean && rm -rf node_modules",
|
||||
"watch": "npx tsc -w"
|
||||
},
|
||||
"bin": {
|
||||
"preserves-schema-ts": "./bin/preserves-schema-ts.js"
|
||||
},
|
||||
"dependencies": {}
|
||||
"prepare": "yarn workspaces run prepare",
|
||||
"clean": "yarn workspaces run clean",
|
||||
"veryclean": "yarn run veryclean:local && yarn workspaces run veryclean",
|
||||
"veryclean:local": "rm -rf node_modules",
|
||||
"build": "yarn workspaces run prepare",
|
||||
"test": "yarn workspaces run test"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
dist/
|
||||
lib/
|
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
"name": "@preserves/core",
|
||||
"version": "0.8.0",
|
||||
"description": "Preserves data serialization format",
|
||||
"homepage": "https://gitlab.com/preserves/preserves",
|
||||
"license": "Apache-2.0",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"repository": "gitlab:preserves/preserves",
|
||||
"main": "dist/preserves.js",
|
||||
"module": "lib/index.js",
|
||||
"types": "lib/index.d.ts",
|
||||
"author": "Tony Garnock-Jones <tonyg@leastfixedpoint.com>",
|
||||
"scripts": {
|
||||
"clean": "rm -rf lib dist",
|
||||
"prepare": "tsc && rollup -c",
|
||||
"rollupwatch": "rollup -c -w",
|
||||
"test": "jest",
|
||||
"testwatch": "jest --watch",
|
||||
"veryclean": "yarn run clean && rm -rf node_modules",
|
||||
"watch": "tsc -w"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
import { terser } from 'rollup-plugin-terser';
|
||||
|
||||
const distfile = (insertion) => `dist/preserves${insertion}.js`;
|
||||
|
||||
function umd(insertion, extra) {
|
||||
return {
|
||||
file: distfile(insertion),
|
||||
format: 'umd',
|
||||
name: 'Preserves',
|
||||
... (extra || {})
|
||||
};
|
||||
}
|
||||
|
||||
function es6(insertion, extra) {
|
||||
return {
|
||||
file: distfile('.es6' + insertion),
|
||||
format: 'es',
|
||||
... (extra || {})
|
||||
};
|
||||
}
|
||||
|
||||
export default [{
|
||||
input: 'lib/index.js',
|
||||
output: [
|
||||
umd(''),
|
||||
umd('.min', { plugins: [terser()] }),
|
||||
es6(''),
|
||||
es6('.min', { plugins: [terser()] }),
|
||||
],
|
||||
}];
|
|
@ -1,6 +1,5 @@
|
|||
export * from './runtime';
|
||||
export * as Constants from './constants';
|
||||
export * as Schema from './schema/index';
|
||||
|
||||
const _Array = Array;
|
||||
type _Array<T> = Array<T>;
|
|
@ -148,7 +148,7 @@ describe('encoding and decoding pointers', () => {
|
|||
});
|
||||
|
||||
describe('common test suite', () => {
|
||||
const samples_bin = fs.readFileSync(__dirname + '/../../../tests/samples.bin');
|
||||
const samples_bin = fs.readFileSync(__dirname + '/../../../../../tests/samples.bin');
|
||||
const samples = decodeWithAnnotations(samples_bin, { decodePointer });
|
||||
|
||||
const TestCases = Record.makeConstructor<{cases: Dictionary<Value<Pointer>, Pointer>}>()(Symbol.for('TestCases'), ['cases']);
|
|
@ -1,12 +1,12 @@
|
|||
import { Bytes, Decoder, encode, Reader } from '../src/index';
|
||||
import './test-utils';
|
||||
import { decodePointer, encodePointer, Pointer } from './test-utils';
|
||||
import { decodePointer, encodePointer } from './test-utils';
|
||||
|
||||
import * as fs from 'fs';
|
||||
|
||||
describe('reading common test suite', () => {
|
||||
const samples_bin = fs.readFileSync(__dirname + '/../../../tests/samples.bin');
|
||||
const samples_txt = fs.readFileSync(__dirname + '/../../../tests/samples.txt', 'utf-8');
|
||||
const samples_bin = fs.readFileSync(__dirname + '/../../../../../tests/samples.bin');
|
||||
const samples_txt = fs.readFileSync(__dirname + '/../../../../../tests/samples.txt', 'utf-8');
|
||||
|
||||
it('should read equal to decoded binary without annotations', () => {
|
||||
const s1 = new Reader(samples_txt, { decodePointer, includeAnnotations: false }).next();
|
|
@ -0,0 +1,2 @@
|
|||
dist/
|
||||
lib/
|
|
@ -0,0 +1,4 @@
|
|||
export default {
|
||||
preset: 'ts-jest',
|
||||
testEnvironment: 'node',
|
||||
};
|
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
"name": "@preserves/schema",
|
||||
"version": "0.0.0",
|
||||
"description": "Schema support for Preserves data serialization format",
|
||||
"homepage": "https://gitlab.com/preserves/preserves",
|
||||
"license": "Apache-2.0",
|
||||
"repository": "gitlab:preserves/preserves",
|
||||
"main": "dist/preserves-schema.js",
|
||||
"module": "lib/index.js",
|
||||
"types": "lib/index.d.ts",
|
||||
"author": "Tony Garnock-Jones <tonyg@leastfixedpoint.com>",
|
||||
"scripts": {
|
||||
"clean": "rm -rf lib dist",
|
||||
"prepare": "tsc && rollup -c",
|
||||
"rollupwatch": "rollup -c -w",
|
||||
"test": "jest",
|
||||
"testwatch": "jest --watch",
|
||||
"veryclean": "yarn run clean && rm -rf node_modules",
|
||||
"watch": "tsc -w"
|
||||
},
|
||||
"bin": {
|
||||
"preserves-schema-ts": "./bin/preserves-schema-ts.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@preserves/core": "^0.8.0"
|
||||
}
|
||||
}
|
|
@ -1,16 +1,15 @@
|
|||
import pkg from './package.json';
|
||||
import { terser } from 'rollup-plugin-terser';
|
||||
|
||||
function distfile(insertion) {
|
||||
const f = `${pkg.name}${insertion}.js`;
|
||||
return `dist/${f}`;
|
||||
}
|
||||
const distfile = (insertion) => `dist/preserves-schema${insertion}.js`;
|
||||
|
||||
function umd(insertion, extra) {
|
||||
return {
|
||||
file: distfile(insertion),
|
||||
format: 'umd',
|
||||
name: 'Preserves',
|
||||
name: 'PreservesSchema',
|
||||
globals: {
|
||||
'@preserves/core': 'Preserves',
|
||||
},
|
||||
... (extra || {})
|
||||
};
|
||||
}
|
||||
|
@ -19,7 +18,10 @@ function es6(insertion, extra) {
|
|||
return {
|
||||
file: distfile('.es6' + insertion),
|
||||
format: 'es',
|
||||
... (extra || {})
|
||||
globals: {
|
||||
'@preserves/core': 'Preserves',
|
||||
},
|
||||
... (extra || {}),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -31,15 +33,17 @@ export default [{
|
|||
es6(''),
|
||||
es6('.min', { plugins: [terser()] }),
|
||||
],
|
||||
external: ['@preserves/core'],
|
||||
}, {
|
||||
input: 'lib/bin/preserves-schema-ts.js',
|
||||
output: [{
|
||||
file: 'dist/bin/preserves-schema-ts.js',
|
||||
format: 'umd',
|
||||
name: 'PreservesC_TS',
|
||||
name: 'PreservesSchemaTS',
|
||||
globals: {
|
||||
'fs': 'fs',
|
||||
'@preserves/core': 'Preserves',
|
||||
},
|
||||
}],
|
||||
external: ['fs'],
|
||||
external: ['fs', '@preserves/core'],
|
||||
}]
|
|
@ -1,4 +1,4 @@
|
|||
import { Record, KeyedDictionary } from '../runtime';
|
||||
import { Record, KeyedDictionary } from '@preserves/core';
|
||||
import { AtomKind, Pattern, Schema } from './meta';
|
||||
import * as M from './meta';
|
||||
|
|
@ -1,12 +1,12 @@
|
|||
import { BASE, compile, readSchema } from '../schema/index';
|
||||
import { BASE, compile, readSchema } from '../index';
|
||||
import fs from 'fs';
|
||||
|
||||
export function main(argv: Array<string>) {
|
||||
console.log('// ' + JSON.stringify(argv));
|
||||
const src = fs.readFileSync(__dirname + '/../../../../schema/schema.txt', 'utf-8');
|
||||
const src = fs.readFileSync(__dirname + '/../../../../../../schema/schema.txt', 'utf-8');
|
||||
const sch = readSchema(src);
|
||||
console.log(compile(
|
||||
[{ moduleName: 'BASE', modulePath: 'BASE', schema: BASE, inline: true }],
|
||||
sch,
|
||||
'..'));
|
||||
'@preserves/core'));
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
import { Pattern, NamedPattern, Schema, Input } from "./meta";
|
||||
import * as M from './meta';
|
||||
import { Annotated, Bytes, Dictionary, Fold, fold, preserves, Record, Tuple, Value } from "../runtime";
|
||||
import { Annotated, Bytes, Dictionary, Fold, fold, preserves, Record, Tuple, Value } from "@preserves/core";
|
||||
import { Formatter, parens, seq, Item, opseq, block, commas, brackets, anglebrackets, braces } from "./block";
|
||||
|
||||
function fnblock(... items: Item[]): Item {
|
||||
|
@ -14,7 +14,7 @@ export type CompileEnvEntry = {
|
|||
inline: boolean,
|
||||
};
|
||||
|
||||
export function compile(env: Array<CompileEnvEntry>, schema: Schema, preservesModule = 'preserves'): string {
|
||||
export function compile(env: Array<CompileEnvEntry>, schema: Schema, preservesModule = '@preserves/core'): string {
|
||||
const literals = new Dictionary<string, never>();
|
||||
const types: Array<Item> = [];
|
||||
const predicates: Array<Item> = [];
|
||||
|
@ -140,7 +140,15 @@ export function compile(env: Array<CompileEnvEntry>, schema: Schema, preservesMo
|
|||
case M.___Symbol: return `typeof ${v} === 'symbol'`;
|
||||
}
|
||||
case M.___lit:
|
||||
return `_.is(${v}, ${literal(p[0])})`;
|
||||
switch (typeof p[0]) {
|
||||
case 'boolean':
|
||||
case 'number':
|
||||
case 'string':
|
||||
case 'symbol':
|
||||
return `${v} === ${literal(p[0])}`;
|
||||
default:
|
||||
return `_.is(${v}, ${literal(p[0])})`;
|
||||
}
|
||||
case M.___ref:
|
||||
return applyPredicate(p[0], v);
|
||||
case M.___or:
|
|
@ -1,6 +1,6 @@
|
|||
import { Environment, Pattern, NamedPattern, lookup } from "./meta";
|
||||
import * as M from './meta';
|
||||
import { Value, Float, Bytes, is, isPointer, Record, Dictionary, Set } from "../runtime";
|
||||
import { Value, Float, Bytes, is, isPointer, Record, Dictionary, Set } from "@preserves/core";
|
||||
|
||||
export function validator(env: Environment, p: Pattern): (v: Value<any>) => boolean {
|
||||
function walk(p: Pattern, v: Value<any>, recordOkAsTuple = false): boolean {
|
|
@ -1,4 +1,4 @@
|
|||
import { Dictionary, KeyedDictionary, Record, Value, preserves } from '../runtime';
|
||||
import { Dictionary, KeyedDictionary, Record, Value, preserves } from '@preserves/core';
|
||||
|
||||
export type Input = Value<never>;
|
||||
|
|
@ -1,8 +1,6 @@
|
|||
import { Annotated, Dictionary, is, KeyedDictionary, peel, preserves, Record, strip, Tuple } from '../runtime';
|
||||
|
||||
import { Reader, Annotated, Dictionary, is, KeyedDictionary, peel, preserves, Record, strip, Tuple } from '@preserves/core';
|
||||
import { Input, NamedPattern, Pattern, Schema } from './meta';
|
||||
import * as M from './meta';
|
||||
import { Reader } from '../reader';
|
||||
|
||||
function splitBy<T>(items: Array<T>, separator: T): Array<Array<T>> {
|
||||
const groups: Array<Array<T>> = [];
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2017",
|
||||
"lib": ["es2019", "DOM"],
|
||||
"declaration": true,
|
||||
"baseUrl": "./src",
|
||||
"rootDir": "./src",
|
||||
"outDir": "./lib",
|
||||
"declarationDir": "./lib",
|
||||
"esModuleInterop": true,
|
||||
"moduleResolution": "node",
|
||||
"sourceMap": true,
|
||||
"strict": true
|
||||
},
|
||||
"include": ["src/**/*"]
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
#!/bin/sh
|
||||
|
||||
cd $(dirname $0)
|
||||
|
||||
first=y
|
||||
|
||||
open() {
|
||||
if [ "$first" = "y" ]
|
||||
then
|
||||
tmux new-window "$1"
|
||||
first=n
|
||||
else
|
||||
tmux split-window "$1" \; select-layout tiled
|
||||
fi
|
||||
}
|
||||
|
||||
open "cd packages/core; yarn run watch"
|
||||
open "cd packages/core; yarn run rollupwatch"
|
||||
open "cd packages/core; yarn run testwatch"
|
||||
open "cd packages/schema; yarn run watch"
|
||||
open "cd packages/schema; yarn run rollupwatch"
|
||||
open "cd packages/schema; yarn run testwatch"
|
||||
|
||||
tmux select-layout even-vertical
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue