Skip to content

Commit

Permalink
Merge pull request #11 from lxfu1/fix/vir-path
Browse files Browse the repository at this point in the history
fix: virtual path
  • Loading branch information
lxfu1 authored May 25, 2021
2 parents 45e4f49 + 2d3b10f commit a93aeab
Show file tree
Hide file tree
Showing 6 changed files with 210 additions and 70 deletions.
105 changes: 54 additions & 51 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,52 +1,55 @@
{
"plugins": ["jest", "@typescript-eslint"],
"extends": ["plugin:github/recommended"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 9,
"sourceType": "module",
"project": "./tsconfig.json"
},
"rules": {
"eslint-comments/no-use": "off",
"import/no-namespace": "off",
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/explicit-member-accessibility": ["error", {"accessibility": "no-public"}],
"@typescript-eslint/no-require-imports": "error",
"@typescript-eslint/array-type": "error",
"@typescript-eslint/await-thenable": "error",
"@typescript-eslint/ban-ts-comment": "error",
"camelcase": "off",
"@typescript-eslint/consistent-type-assertions": "error",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/func-call-spacing": ["error", "never"],
"@typescript-eslint/no-array-constructor": "error",
"@typescript-eslint/no-empty-interface": "error",
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-extraneous-class": "error",
"@typescript-eslint/no-for-in-array": "error",
"@typescript-eslint/no-inferrable-types": "error",
"@typescript-eslint/no-misused-new": "error",
"@typescript-eslint/no-namespace": "error",
"@typescript-eslint/no-non-null-assertion": "warn",
"@typescript-eslint/no-unnecessary-qualifier": "error",
"@typescript-eslint/no-unnecessary-type-assertion": "error",
"@typescript-eslint/no-useless-constructor": "error",
"@typescript-eslint/no-var-requires": "error",
"@typescript-eslint/prefer-for-of": "warn",
"@typescript-eslint/prefer-function-type": "warn",
"@typescript-eslint/prefer-includes": "error",
"@typescript-eslint/prefer-string-starts-ends-with": "error",
"@typescript-eslint/promise-function-async": "error",
"@typescript-eslint/require-array-sort-compare": "error",
"@typescript-eslint/restrict-plus-operands": "error",
"@typescript-eslint/type-annotation-spacing": "error",
"@typescript-eslint/unbound-method": "error"
},
"env": {
"node": true,
"es6": true,
"jest/globals": true
}
}
"plugins": ["jest", "@typescript-eslint"],
"extends": ["plugin:github/recommended"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 9,
"sourceType": "module",
"project": "./tsconfig.json"
},
"rules": {
"eslint-comments/no-use": "off",
"import/no-namespace": "off",
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/explicit-member-accessibility": [
"error",
{ "accessibility": "no-public" }
],
"@typescript-eslint/no-require-imports": "error",
"@typescript-eslint/array-type": "error",
"@typescript-eslint/await-thenable": "error",
"@typescript-eslint/ban-ts-comment": "error",
"camelcase": "off",
"@typescript-eslint/consistent-type-assertions": "error",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/func-call-spacing": ["error", "never"],
"@typescript-eslint/no-array-constructor": "error",
"@typescript-eslint/no-empty-interface": "error",
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-extraneous-class": "error",
"@typescript-eslint/no-for-in-array": "error",
"@typescript-eslint/no-inferrable-types": "error",
"@typescript-eslint/no-misused-new": "error",
"@typescript-eslint/no-namespace": "error",
"@typescript-eslint/no-non-null-assertion": "warn",
"@typescript-eslint/no-unnecessary-qualifier": "error",
"@typescript-eslint/no-unnecessary-type-assertion": "error",
"@typescript-eslint/no-useless-constructor": "error",
"@typescript-eslint/no-var-requires": "error",
"@typescript-eslint/prefer-for-of": "warn",
"@typescript-eslint/prefer-function-type": "warn",
"@typescript-eslint/prefer-includes": "error",
"@typescript-eslint/prefer-string-starts-ends-with": "error",
"@typescript-eslint/promise-function-async": "error",
"@typescript-eslint/require-array-sort-compare": "error",
"@typescript-eslint/restrict-plus-operands": "error",
"@typescript-eslint/type-annotation-spacing": "error",
"@typescript-eslint/unbound-method": "error"
},
"env": {
"node": true,
"es6": true,
"jest/globals": true
}
}
121 changes: 121 additions & 0 deletions dist/exec-child.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 5 additions & 9 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

14 changes: 5 additions & 9 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,19 @@ import * as github from '@actions/github';
import { exec } from '@actions/exec';
import { comment } from './commentToPullRequest';
import { execSurgeCommand, formatImage, getCommentFooter } from './helpers';
// import { initPublic } from './sh.js';

let failOnErrorGlobal = false;
let fail: (err: Error) => void;

async function build() {
async function initPublic() {
return new Promise(async (resovle) => {
const project_name = core.getInput('project_name') || 'G2Plot';
const project_branch = core.getInput('project_branch') || 'master';
await exec('cd ..');
await exec('git clone https://github.com/lxfu1/surge-preview.git');
await exec(`ls`);
await exec('git clone https://github.com/lxfu1/surge-preview.git');
await exec(`npx sh start.sh ${project_name} ${project_branch}`);
await exec(`mkdir public`);
await exec(`cp -r ../public/* ./pub`);
await exec(`ls`);
// await exec(`npx sh start.sh ${project_name} ${project_branch}`);
// await exec(`ls ./pub/preview`);
await exec(`ls pub/preview`);
resovle(null);
});
}
Expand Down Expand Up @@ -198,7 +194,7 @@ ${getCommentFooter()}
}

async function flow() {
await build();
await initPublic();
// eslint-disable-next-line github/no-then
main().catch((err) => {
fail?.(err);
Expand Down
24 changes: 24 additions & 0 deletions src/sh.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const shell = require('shelljs');
const core = require('@actions/core');

export const initPublic = async () => {
return new Promise(async (resovle) => {
const project_name = core.getInput('project_name') || 'G2Plot';
const project_branch = core.getInput('project_branch') || 'master';
core.info('surgeToken');
shell.exec('mkdir tempPub');
shell.exec(`ls`);
shell.exec('cd ./tempPub');
shell.exec(`ls`);
shell.exec('git clone https://github.com/lxfu1/surge-preview.git');
shell.exec(`ls`);
shell.exec(`npx sh start.sh ${project_name} ${project_branch}`);
shell.exec('cd ..');
shell.exec(`mkdir pub`);
shell.exec(`cp -r ../public/* ./pub`);
shell.exec(`ls`);
// shell.exec(`npx sh start.sh ${project_name} ${project_branch}`);
// shell.exec(`ls ./pub/preview`);
resovle(null);
});
};

0 comments on commit a93aeab

Please sign in to comment.