Skip to content

Commit

Permalink
Feature/cli param (#2)
Browse files Browse the repository at this point in the history
* removed apps file

* added cli folder

* added template args

* added command option parsing

* added command behaviors

* changed package version

* added publish CI
  • Loading branch information
hoonsubin authored Oct 30, 2020
1 parent c6a1353 commit 7b72501
Show file tree
Hide file tree
Showing 13 changed files with 321 additions and 183 deletions.
32 changes: 0 additions & 32 deletions .github/workflows/deploy_action.yml

This file was deleted.

17 changes: 17 additions & 0 deletions .github/workflows/publish_action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Publish to NPM
on:
release:
types: [created]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: "12.x"
registry-url: "https://registry.npmjs.org"
- run: yarn
- run: npm publish --access=public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
7 changes: 7 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
tests
scripts
src
img
.vscode
.github
*.md
23 changes: 20 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "glitch-deploy-tool",
"version": "1.0.0",
"version": "0.0.1-alpha",
"description": "CLI tool for deploying files to Glitch.com",
"keywords": [
"glitch.com",
Expand All @@ -20,20 +20,36 @@
"type": "git",
"url": "https://github.com/hoonsubin/glitch-deploy-tool.git"
},
"main": "src/index.ts",
"files": [
"lib"
],
"os": [
"darwin",
"linux"
],
"module": "lib/index.js",
"bin": {
"glitch-deploy-tool": "lib/cli/index.js"
},
"scripts": {
"start": "NODE_ENV=production ts-node -r dotenv/config src/index.ts",
"dev": "NODE_ENV=development ts-node-dev -r dotenv/config src/index.ts",
"prepublishOnly": "yarn run test && yarn run lint && yarn run build",
"build": "rimraf ./lib && tsc --project tsconfig.json",
"lint": "eslint '*/**/*.{js,ts,tsx}' --quiet --fix",
"test": "NODE_ENV=test jest --setupFiles dotenv/config --verbose --coverage && eslint '*/**/*.{js,ts,tsx}'",
"cli": "NODE_ENV=development ts-node -r dotenv/config scripts/cli.ts"
"cli": "NODE_ENV=development ts-node -r dotenv/config src/cli/index.ts"
},
"engines": {
"node": ">=12.x"
},
"funding": {
"type": "patreon",
"url": "https://www.patreon.com/teamstep"
},
"license": "MIT",
"devDependencies": {
"@types/dashdash": "^1.14.0",
"@types/fs-extra": "^9.0.2",
"@types/jest": "^26.0.15",
"@types/nock": "^11.1.0",
Expand All @@ -56,6 +72,7 @@
"typescript": "^4.0.5"
},
"dependencies": {
"dashdash": "^2.0.0",
"fs-extra": "^9.0.1",
"node": "^15.0.1",
"node-fetch": "^2.6.1",
Expand Down
97 changes: 0 additions & 97 deletions scripts/cli.ts

This file was deleted.

51 changes: 51 additions & 0 deletions scripts/run.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/env ts-node
//note: this cli script is for testing and being executed directly from source

import path from 'path';
import { GlitchGit, GlitchProject } from '../src/models';

const gitPushTest = async () => {
const source = process.env.REPO_SOURCE;

if (typeof source === 'undefined') {
throw new Error('target repository has not been provided');
}

// the folder to where it will copy things
const targetFolder = 'target';

const glitchRepo = new GlitchGit(source, true);

await glitchRepo.publishFilesToGlitch(path.join(__dirname, targetFolder));
};

const gitImportTest = async () => {
const projId = process.env.GLITCH_PROJ_ID;
const token = process.env.GLITCH_USER_TOKEN;

if (typeof projId === 'undefined' || typeof token === 'undefined') {
throw new Error('the required environment variables were not provided');
}

const sourceRepo = 'staketechnologies/lockdrop-ui';
const glitchProj = new GlitchProject(token, projId);

const res = await glitchProj.importFromGithub(sourceRepo, 'public');

if (res.status !== 200) {
throw new Error('Failed to import project');
}
console.log('successfully imported project ' + sourceRepo);
};

// script entry point
(async () => {
throw new Error('Script not implemented!');
//await gitPushTest();
//await gitImportTest();

//process.exit(0);
})().catch((err) => {
console.error(err);
process.exit(1);
});
7 changes: 0 additions & 7 deletions src/app.ts

This file was deleted.

23 changes: 23 additions & 0 deletions src/cli/deploy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { GlitchGit, GlitchProject } from '../models';

export const importFromFolder = async (repoUrl: string, targetPath?: string, debugMessage?: boolean) => {
const glitchRepo = new GlitchGit(repoUrl, debugMessage);

await glitchRepo.publishFilesToGlitch(targetPath);

console.log('successfully imported projects from ' + targetPath);
};

export const importFromGithub = async (token: string, projId: string, repo: string, path?: string) => {
if (typeof projId === 'undefined' || typeof token === 'undefined') {
throw new Error('the required environment variables were not provided');
}
const glitchProj = new GlitchProject(token, projId);

const res = await glitchProj.importFromGithub(repo, path);

if (res.status !== 200) {
throw new Error('Failed to import project');
}
console.log('successfully imported project ' + repo);
};
Loading

0 comments on commit 7b72501

Please sign in to comment.