Skip to content

Commit

Permalink
Merge pull request #63 from Eyas/no-gulp
Browse files Browse the repository at this point in the history
Cleanup Dependencies & Reduce Gulp Usage
  • Loading branch information
Eyas committed Jan 15, 2020
2 parents bcec885 + 65d0126 commit 8a1ead3
Show file tree
Hide file tree
Showing 5 changed files with 422 additions and 446 deletions.
31 changes: 24 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,23 @@ The Schema Typings Generator is available in the

Command line usage:

- **`schema`** and **`layer`**: Used to load the actual Schema definition:
- **Specify your ontology**
- (*Default*) From Schema.org: Specify **`--schema`** and **`--layer`**:
Your schema definition will be imported from.

https://schema.org/version/${schema}/${layer}.nt
https://schema.org/version/${schema}/${layer}.nt

- **`context`**: Defaults to `https://schema.org`, the value or values to be
This will be used by default, with `--schema=latest` and
`--layer=all-layers`, which includes pending, life sciences, and other
schemas.

- From a custom URL: Specify **`--ontology`**: An HTTPs URL to an .nt NTriple
file declaring your ontology.

Must be compatible with Schema.org, including the Schema.org `DataType`s and
specifying a top-level `Thign` type.

- **`--context`**: Defaults to `https://schema.org`, the value or values to be
used with the `"@context"` property.

Can be either a single URL, or a comma separated list of two or more name:URL
Expand All @@ -76,22 +88,27 @@ Command line usage:
The context affects names of string properties in types, as well as the values
of an object's `"@type"`.

- **`deprecated`**/**`nodeprecated`**: Whether or not to include deprecated
- **`--deprecated`**/**`--nodeprecated`**: Whether or not to include deprecated
Schema.org types and properties. When included, these types will still be
marked with `@deprecated` JSDOC tags.

- **`--verbose`**: Outputs additional logs and debugging notes to stderr.

## Developers

Use NPM to install dependencies:

npm install

Use Gulp to build the package:
We have wrappers around `tsc` and `tsc --build` to build our generator other
.d.ts files.

To generate TypeScript from the latest Schema.org Schema:

gulp generate-ts
npm run build-gen && npm run build-schema

or simply build the schema-dts generator:

gulp build-generator
npm run build-gen

To contribute changes, see [the CONTRIBUTING.md file](./CONTRIBUTING.md).
59 changes: 1 addition & 58 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,69 +15,12 @@
*/

const gulp = require('gulp');
const tsc = require('gulp-typescript');
const file = require('gulp-file');
const del = require('del');

const cpSpwan = require('child_process').spawn;
const through2 = require('through2');
function spawn(command, args = [], options = {}) {
if (!options.env) {
options.env = process.env;
}
if (!options.cwd) {
options.cwd = process.cwd();
}
return through2.obj(function(file, _, flush) {
const cp = cpSpwan(command, args, options);
cp.stderr.on(
'data', err => console.error(Buffer.from(err).toString('utf-8')));
cp.on('error', err => console.log(err));

file.contents = cp.stdout;
this.push(file);
cp.on('close', () => {
flush();
});
});
}

gulp.task('clean', () => del([
'built',
'dist/src',
'dist/gen',
'dist/schema/**/*',
'!dist/schema/package.json',
'!dist/schema/README.md',
]));

const nodeProject = tsc.createProject('src/tsconfig.json');
gulp.task('build-generator', () => {
return nodeProject.src().pipe(nodeProject()).pipe(gulp.dest('built/src'));
});

gulp.task('generate-ts', gulp.series('build-generator', () => {
return file('schema.ts', '', {src: true})
.pipe(spawn('node', ['built/src/cli/cli.js']))
.pipe(gulp.dest('built/ts-schema'));
}));

gulp.task(
'prepare-package',
() => gulp.src(['LICENSE']).pipe(gulp.dest('dist/schema')));

gulp.task(
'generate-package',
gulp.series(
'clean',
gulp.parallel('generate-ts', 'prepare-package'),
gulp.parallel(
() => {
return gulp.src('built/ts-schema/*.ts')
.pipe(tsc({
noImplicitAny: true,
declaration: true,
}))
.pipe(gulp.dest('dist/schema'));
},
() => gulp.src('built/src/**/*').pipe(gulp.dest('dist/gen'))),
));

0 comments on commit 8a1ead3

Please sign in to comment.