Skip to content

Commit

Permalink
Add dist to repo
Browse files Browse the repository at this point in the history
  • Loading branch information
smyrick committed Nov 12, 2024
1 parent 32b7684 commit 175ff00
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 31 deletions.
37 changes: 7 additions & 30 deletions .github/workflows/onPushToMain.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# test
name: version, tag and github release
name: Build latest and update README

on:
push:
Expand All @@ -11,38 +10,16 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- name: Check if version already exists
id: version-check
run: |
package_version=$(node -p "require('./package.json').version")
exists=$(gh api repos/${{ github.repository }}/releases/tags/v$package_version >/dev/null 2>&1 && echo "true" || echo "")
if [ -n "$exists" ];
then
echo "Version v$package_version already exists"
echo "::warning file=package.json,line=1::Version v$package_version already exists - no release will be created. If you want to create a new release, please update the version in package.json and push again."
echo "skipped=true" >> $GITHUB_OUTPUT
else
echo "Version v$package_version does not exist. Creating release..."
echo "skipped=false" >> $GITHUB_OUTPUT
echo "tag=v$package_version" >> $GITHUB_OUTPUT
fi
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
- name: Setup git
if: ${{ steps.version-check.outputs.skipped == 'false' }}
run: |
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com"
- name: Generate oclif README
if: ${{ steps.version-check.outputs.skipped == 'false' }}
id: oclif-readme
- name: Generate latest build
id: build
run: |
npm install
npm run build
npm exec oclif readme
if [ -n "$(git status --porcelain)" ]; then
git add README.md
git commit -am "chore: update README.md"
git push -u origin ${{ github.ref_name }}
fi
npm run verison
git add .
git commit -am "chore: update build"
git push -u origin ${{ github.ref_name }}
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ ehthumbs.db
**/.DS_Store

# Build
/dist
/tmp
oclif.manifest.json

Expand Down
14 changes: 14 additions & 0 deletions dist/commands/mock/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Command } from '@oclif/core';
export default class Mock extends Command {
static args: {
schema: import("@oclif/core/interfaces").Arg<string, {
exists?: boolean;
}>;
};
static description: string;
static examples: string[];
static flags: {
port: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
};
run(): Promise<void>;
}
27 changes: 27 additions & 0 deletions dist/commands/mock/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { Args, Command, Flags } from '@oclif/core';
import { readFileSync } from 'node:fs';
import { startServer } from '../../common/server.js';
export default class Mock extends Command {
static args = {
schema: Args.file({ description: 'Schema file to mock', required: true }),
};
static description = 'Start a mock GraphQL server from a file';
static examples = [
'<%= config.bin %> <%= command.id %> schema.graphql',
'<%= config.bin %> <%= command.id %> schema.graphql --port 8080',
];
static flags = {
port: Flags.integer({
default: 4000,
description: 'HTTP port for server',
required: false
})
};
async run() {
const { args, flags } = await this.parse(Mock);
this.log(`Reading schema file ${args.schema}...`);
const sdl = readFileSync(args.schema, 'utf8');
const promise = await startServer(sdl, flags.port);
this.log(`🚀 Mock Apollo Server ready at: ${promise.url}`);
}
}
3 changes: 3 additions & 0 deletions dist/common/server.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export declare const startServer: (sdl: string, port: number) => Promise<{
url: string;
}>;
16 changes: 16 additions & 0 deletions dist/common/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { ApolloServer } from '@apollo/server';
import { startStandaloneServer } from '@apollo/server/standalone';
import { addMocksToSchema } from '@graphql-tools/mock';
import { makeExecutableSchema } from '@graphql-tools/schema';
const getApolloServer = (sdl) => new ApolloServer({
introspection: true,
schema: addMocksToSchema({
schema: makeExecutableSchema({ typeDefs: sdl })
})
});
export const startServer = async (sdl, port) => {
const server = getApolloServer(sdl);
return startStandaloneServer(server, {
listen: { port },
});
};
1 change: 1 addition & 0 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { run } from '@oclif/core';
1 change: 1 addition & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { run } from '@oclif/core';

0 comments on commit 175ff00

Please sign in to comment.