Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tony's changes #1

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,25 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
node-version: [6.x, 8.x, 10.x, 12.x]
node-version: [10.x, 12.x]

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- name: node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- name: updating npm
run: npm i -g npm
- name: Get npm cache directory
id: npm-cache-dir
run: |
echo "::set-output name=dir::$(npm config get cache)"
- uses: actions/cache@v2
id: npm-cache # use this to check for `cache-hit` ==> if: steps.npm-cache.outputs.cache-hit != 'true'
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: installing
run: npm ci
- name: build
Expand All @@ -33,9 +42,9 @@ jobs:
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- name: node.js 14
uses: actions/setup-node@v1
uses: actions/setup-node@v2
with:
node-version: 14
- name: installing
Expand Down
34 changes: 27 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,25 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
node-version: [6.x, 8.x, 10.x, 12.x]
node-version: [10.x, 12.x]

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- name: node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- name: updating npm
run: npm i -g npm
- name: Get npm cache directory
id: npm-cache-dir
run: |
echo "::set-output name=dir::$(npm config get cache)"
- uses: actions/cache@v2
id: npm-cache # use this to check for `cache-hit` ==> if: steps.npm-cache.outputs.cache-hit != 'true'
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: installing
run: npm ci
- name: testing
Expand All @@ -31,11 +40,22 @@ jobs:
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- name: node.js 14
uses: actions/setup-node@v1
uses: actions/setup-node@v2
with:
node-version: 14
- name: Get npm cache directory
id: npm-cache-dir
run: |
echo "::set-output name=dir::$(npm config get cache)"
- uses: actions/cache@v2
id: npm-cache # use this to check for `cache-hit` ==> if: steps.npm-cache.outputs.cache-hit != 'true'
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: installing
run: npm ci
- name: testing
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.json
18 changes: 9 additions & 9 deletions lib/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
ListValueFlag,
NoParams,
OutputInterface,
ValueFlag
ValueFlag,
} from "@2fd/command";
import Bluebird from "bluebird";
import fs from "fs";
Expand All @@ -17,15 +17,15 @@ import {
httpSchemaLoader,
idlSchemaLoader,
jsonSchemaLoader,
jsSchemaLoader
jsSchemaLoader,
} from "./schema-loader";
import { createData, getFilenameOf, Output, Plugin } from "./utility";
import {
createBuildDirectory,
readFile,
removeBuildDirectory,
resolve,
writeFile
writeFile,
} from "./utility/fs";

// tslint:disable-next-line:no-var-requires
Expand Down Expand Up @@ -116,7 +116,7 @@ export class GraphQLDocumentGenerator extends Command<IFlags, {}> {
"Delete outputDirectory if exists."
),
new BooleanFlag("verbose", ["-v", "--verbose"], "Output more information."),
new BooleanFlag("version", ["-V", "--version"], "Show graphdoc version.")
new BooleanFlag("version", ["-V", "--version"], "Show graphdoc version."),
];

public async action(input: Input, out: OutputInterface) {
Expand All @@ -143,13 +143,13 @@ export class GraphQLDocumentGenerator extends Command<IFlags, {}> {
graphdocPackageJSON
);

projectPackageJSON.graphdoc.plugins.forEach(plugin =>
projectPackageJSON.graphdoc.plugins.forEach((plugin) =>
output.info("use plugin", plugin)
);

// Collect assets
const assets: string[] = await Plugin.collectAssets(plugins);
assets.forEach(asset =>
assets.forEach((asset) =>
output.info("use asset", path.relative(process.cwd(), asset))
);

Expand Down Expand Up @@ -261,7 +261,7 @@ export class GraphQLDocumentGenerator extends Command<IFlags, {}> {
projectPackageJSON: object,
pluginGraphdocPackageJSON: object
): PluginInterface[] {
return paths.map(p => {
return paths.map((p) => {
const absolutePaths = resolve(p);
const plugin = require(absolutePaths).default;

Expand All @@ -284,10 +284,10 @@ export class GraphQLDocumentGenerator extends Command<IFlags, {}> {
)("**/*.mustache", { cwd: templateDir });

await Promise.all(
files.map(file => {
files.map((file) => {
const name = path.basename(file, ".mustache");
return readFile(path.resolve(templateDir, file), "utf8").then(
content => (partials[name] = content)
(content) => (partials[name] = content)
);
})
);
Expand Down
4 changes: 2 additions & 2 deletions lib/schema-loader/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
GraphQLIntrospection,
Introspection,
Schema,
SchemaLoader
SchemaLoader,
} from "../interface";
import { query as introspectionQuery } from "../utility";

Expand Down Expand Up @@ -62,7 +62,7 @@ export const httpSchemaLoader: SchemaLoader = async (
url: options.endpoint,
method: "POST",
body: { query: introspectionQuery },
json: true
json: true,
};

requestOptions.headers = options.headers.reduce(
Expand Down
2 changes: 1 addition & 1 deletion lib/schema-loader/idl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
ApolloIntrospection,
GraphQLIntrospection,
Introspection,
SchemaLoader
SchemaLoader,
} from "../interface";
import { query as introspectionQuery } from "../utility";
import { readFile } from "../utility/fs";
Expand Down
4 changes: 2 additions & 2 deletions lib/schema-loader/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ export { IHttpSchemaLoaderOptions, httpSchemaLoader } from "./http";
export { IIdlSchemaLoaderOptions, idlSchemaLoader } from "./idl";
export {
IJsSchemaLoaderOptions as TJsSchemaLoaderOptions,
jsSchemaLoader
jsSchemaLoader,
} from "./js";
export {
IJsonSchemaLoaderOptions as TJsonSchemaLoaderOptions,
jsonSchemaLoader
jsonSchemaLoader,
} from "./json";
2 changes: 1 addition & 1 deletion lib/schema-loader/js.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
ApolloIntrospection,
GraphQLIntrospection,
Introspection,
SchemaLoader
SchemaLoader,
} from "../interface";
import { query as introspectionQuery } from "../utility";

Expand Down
2 changes: 1 addition & 1 deletion lib/schema-loader/json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
GraphQLIntrospection,
Introspection,
Schema,
SchemaLoader
SchemaLoader,
} from "../interface";

export interface IJsonSchemaLoaderOptions {
Expand Down
6 changes: 3 additions & 3 deletions lib/utility/fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ export async function createBuildDirectory(
files

// ignore *.mustache templates
.filter(file => path.extname(file) !== ".mustache")
.filter((file) => path.extname(file) !== ".mustache")

// copy recursive
.map(file =>
.map((file) =>
copyAll(
path.resolve(templateDirectory, file),
path.resolve(buildDirectory, file)
Expand All @@ -71,7 +71,7 @@ export async function createBuildDirectory(
await mkDir(path.resolve(buildDirectory, "assets"));

await Bluebird.all(
assets.map(asset =>
assets.map((asset) =>
copyAll(
asset,
path.resolve(buildDirectory, "assets", path.basename(asset))
Expand Down
Loading