chore: change printWidth from 80 to 100 (#362)

This commit is contained in:
Shohei Ueda 2020-06-22 05:40:26 +09:00 committed by GitHub
parent b6801e6334
commit 4d89a385db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 32 additions and 128 deletions

View File

@ -1,5 +1,5 @@
{
"printWidth": 80,
"printWidth": 100,
"tabWidth": 2,
"useTabs": false,
"semi": true,

View File

@ -9,9 +9,7 @@ beforeEach(() => {
jest.resetModules();
process.stdout.write = jest.fn();
const doc = yaml.safeLoad(
fs.readFileSync(__dirname + '/../action.yml', 'utf8')
);
const doc = yaml.safeLoad(fs.readFileSync(__dirname + '/../action.yml', 'utf8'));
Object.keys(doc.inputs).forEach(name => {
const envVar = `INPUT_${name.replace(/ /g, '_').toUpperCase()}`;
process.env[envVar] = doc.inputs[name]['default'];
@ -19,9 +17,7 @@ beforeEach(() => {
});
afterEach(() => {
const doc = yaml.safeLoad(
fs.readFileSync(__dirname + '/../action.yml', 'utf8')
);
const doc = yaml.safeLoad(fs.readFileSync(__dirname + '/../action.yml', 'utf8'));
Object.keys(doc.inputs).forEach(name => {
const envVar = `INPUT_${name.replace(/ /g, '_').toUpperCase()}`;
console.debug(`delete ${envVar}\t${process.env[envVar]}`);

View File

@ -1,9 +1,4 @@
import {
getUserName,
getUserEmail,
setCommitAuthor,
getCommitMessage
} from '../src/git-utils';
import {getUserName, getUserEmail, setCommitAuthor, getCommitMessage} from '../src/git-utils';
import {getWorkDirName, createWorkDir} from '../src/utils';
import {CmdResult} from '../src/interfaces';
import * as exec from '@actions/exec';
@ -138,13 +133,7 @@ describe('getCommitMessage()', () => {
});
test('get custom message', () => {
const test = getCommitMessage(
'Custom msg',
'',
'',
'actions/pages',
'commit_hash'
);
const test = getCommitMessage('Custom msg', '', '', 'actions/pages', 'commit_hash');
expect(test).toMatch('Custom msg commit_hash');
});
@ -160,13 +149,7 @@ describe('getCommitMessage()', () => {
});
test('get full custom message', () => {
const test = getCommitMessage(
'',
'Full custom msg',
'',
'actions/pages',
'commit_hash'
);
const test = getCommitMessage('', 'Full custom msg', '', 'actions/pages', 'commit_hash');
expect(test).toMatch('Full custom msg');
});

View File

@ -1,8 +1,4 @@
import {
getPublishRepo,
setPersonalToken,
setGithubToken
} from '../src/set-tokens';
import {getPublishRepo, setPersonalToken, setGithubToken} from '../src/set-tokens';
beforeEach(() => {
jest.resetModules();
@ -26,8 +22,7 @@ describe('getPublishRepo()', () => {
describe('setGithubToken()', () => {
test('return remote url with GITHUB_TOKEN gh-pages', () => {
const expected =
'https://x-access-token:GITHUB_TOKEN@github.com/owner/repo.git';
const expected = 'https://x-access-token:GITHUB_TOKEN@github.com/owner/repo.git';
const test = setGithubToken(
'GITHUB_TOKEN',
'owner/repo',
@ -40,8 +35,7 @@ describe('setGithubToken()', () => {
});
test('return remote url with GITHUB_TOKEN master', () => {
const expected =
'https://x-access-token:GITHUB_TOKEN@github.com/owner/repo.git';
const expected = 'https://x-access-token:GITHUB_TOKEN@github.com/owner/repo.git';
const test = setGithubToken(
'GITHUB_TOKEN',
'owner/repo',
@ -55,14 +49,7 @@ describe('setGithubToken()', () => {
test('throw error master to master', () => {
expect(() => {
setGithubToken(
'GITHUB_TOKEN',
'owner/repo',
'master',
'',
'refs/heads/master',
'push'
);
setGithubToken('GITHUB_TOKEN', 'owner/repo', 'master', '', 'refs/heads/master', 'push');
}).toThrowError('You deploy from master to master');
});
@ -76,14 +63,11 @@ describe('setGithubToken()', () => {
'refs/heads/master',
'push'
);
}).toThrowError(
'GITHUB_TOKEN does not support to push to an external repository'
);
}).toThrowError('GITHUB_TOKEN does not support to push to an external repository');
});
test('return remote url with GITHUB_TOKEN pull_request', () => {
const expected =
'https://x-access-token:GITHUB_TOKEN@github.com/owner/repo.git';
const expected = 'https://x-access-token:GITHUB_TOKEN@github.com/owner/repo.git';
const test = setGithubToken(
'GITHUB_TOKEN',
'owner/repo',

View File

@ -27,7 +27,7 @@
}
},
"lint-staged": {
"src/**/*.ts": [
"{src,__tests__}/**/*.ts": [
"prettier --check",
"eslint"
],

View File

@ -53,12 +53,9 @@ export function getInputs(): Inputs {
PublishBranch: core.getInput('publish_branch'),
PublishDir: core.getInput('publish_dir'),
ExternalRepository: core.getInput('external_repository'),
AllowEmptyCommit:
(core.getInput('allow_empty_commit') || 'false').toUpperCase() === 'TRUE',
KeepFiles:
(core.getInput('keep_files') || 'false').toUpperCase() === 'TRUE',
ForceOrphan:
(core.getInput('force_orphan') || 'false').toUpperCase() === 'TRUE',
AllowEmptyCommit: (core.getInput('allow_empty_commit') || 'false').toUpperCase() === 'TRUE',
KeepFiles: (core.getInput('keep_files') || 'false').toUpperCase() === 'TRUE',
ForceOrphan: (core.getInput('force_orphan') || 'false').toUpperCase() === 'TRUE',
UserName: core.getInput('user_name'),
UserEmail: core.getInput('user_email'),
CommitMessage: core.getInput('commit_message'),

View File

@ -12,10 +12,7 @@ export async function createBranchForce(branch: string): Promise<void> {
return;
}
export async function copyAssets(
publishDir: string,
workDir: string
): Promise<void> {
export async function copyAssets(publishDir: string, workDir: string): Promise<void> {
const copyOpts = {recursive: true, force: true};
const files = fs.readdirSync(publishDir);
core.debug(`${files}`);
@ -31,15 +28,8 @@ export async function copyAssets(
return;
}
export async function setRepo(
inps: Inputs,
remoteURL: string,
workDir: string
): Promise<void> {
const publishDir = path.join(
`${process.env.GITHUB_WORKSPACE}`,
inps.PublishDir
);
export async function setRepo(inps: Inputs, remoteURL: string, workDir: string): Promise<void> {
const publishDir = path.join(`${process.env.GITHUB_WORKSPACE}`, inps.PublishDir);
core.info(`[INFO] ForceOrphan: ${inps.ForceOrphan}`);
if (inps.ForceOrphan) {
@ -65,15 +55,7 @@ export async function setRepo(
try {
result.exitcode = await exec.exec(
'git',
[
'clone',
'--depth=1',
'--single-branch',
'--branch',
inps.PublishBranch,
remoteURL,
workDir
],
['clone', '--depth=1', '--single-branch', '--branch', inps.PublishBranch, remoteURL, workDir],
options
);
if (result.exitcode === 0) {
@ -90,9 +72,7 @@ export async function setRepo(
throw new Error(`Failed to clone remote branch ${inps.PublishBranch}`);
}
} catch (e) {
core.info(
`[INFO] first deployment, create new branch ${inps.PublishBranch}`
);
core.info(`[INFO] first deployment, create new branch ${inps.PublishBranch}`);
core.info(e.message);
await createWorkDir(workDir);
process.chdir(workDir);
@ -118,10 +98,7 @@ export function getUserEmail(userEmail: string): string {
}
}
export async function setCommitAuthor(
userName: string,
userEmail: string
): Promise<void> {
export async function setCommitAuthor(userName: string, userEmail: string): Promise<void> {
if (userName && !userEmail) {
throw new Error('user_email is undefined');
}
@ -160,10 +137,7 @@ export function getCommitMessage(
return subject;
}
export async function commit(
allowEmptyCommit: boolean,
msg: string
): Promise<void> {
export async function commit(allowEmptyCommit: boolean, msg: string): Promise<void> {
try {
if (allowEmptyCommit) {
await exec.exec('git', ['commit', '--allow-empty', '-m', `${msg}`]);
@ -176,10 +150,7 @@ export async function commit(
}
}
export async function push(
branch: string,
forceOrphan: boolean
): Promise<void> {
export async function push(branch: string, forceOrphan: boolean): Promise<void> {
if (forceOrphan) {
await exec.exec('git', ['push', 'origin', '--force', branch]);
} else {
@ -187,10 +158,7 @@ export async function push(
}
}
export async function pushTag(
tagName: string,
tagMessage: string
): Promise<void> {
export async function pushTag(tagName: string, tagMessage: string): Promise<void> {
if (tagName === '') {
return;
}

View File

@ -5,14 +5,7 @@ import * as github from '@actions/github';
import {Inputs} from './interfaces';
import {showInputs, getInputs} from './get-inputs';
import {setTokens} from './set-tokens';
import {
setRepo,
setCommitAuthor,
getCommitMessage,
commit,
push,
pushTag
} from './git-utils';
import {setRepo, setCommitAuthor, getCommitMessage, commit, push, pushTag} from './git-utils';
import {getWorkDirName, addNoJekyll, addCNAME, skipOnFork} from './utils';
export async function run(): Promise<void> {
@ -39,9 +32,7 @@ export async function run(): Promise<void> {
inps.PersonalToken
);
if (isSkipOnFork) {
core.warning(
'This action runs on a fork and not found auth token, Skip deployment'
);
core.warning('This action runs on a fork and not found auth token, Skip deployment');
core.setOutput('skip', 'true');
return;
}

View File

@ -9,10 +9,7 @@ const cpexec = require('child_process').execFileSync;
import {Inputs} from './interfaces';
import {getHomeDir} from './utils';
export async function setSSHKey(
inps: Inputs,
publishRepo: string
): Promise<string> {
export async function setSSHKey(inps: Inputs, publishRepo: string): Promise<string> {
core.info('[INFO] setup SSH deploy key');
const homeDir = await getHomeDir();
@ -81,27 +78,18 @@ export function setGithubToken(
}
if (externalRepository) {
throw new Error(
'GITHUB_TOKEN does not support to push to an external repository'
);
throw new Error('GITHUB_TOKEN does not support to push to an external repository');
}
return `https://x-access-token:${githubToken}@github.com/${publishRepo}.git`;
}
export function setPersonalToken(
personalToken: string,
publishRepo: string
): string {
export function setPersonalToken(personalToken: string, publishRepo: string): string {
core.info('[INFO] setup personal access token');
return `https://x-access-token:${personalToken}@github.com/${publishRepo}.git`;
}
export function getPublishRepo(
externalRepository: string,
owner: string,
repo: string
): string {
export function getPublishRepo(externalRepository: string, owner: string, repo: string): string {
if (externalRepository) {
return externalRepository;
}

View File

@ -47,10 +47,7 @@ export async function addNoJekyll(
}
}
export async function addCNAME(
workDir: string,
content: string
): Promise<void> {
export async function addCNAME(workDir: string, content: string): Promise<void> {
if (content === '') {
return;
}