rename project to Copykitku
This commit is contained in:
parent
d19a3653a9
commit
0378d988c6
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"name": "git-copycat",
|
"name": "copykitku",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"author": "selfisekai <laura@selfisekai.rocks>",
|
"author": "selfisekai <laura@selfisekai.rocks>",
|
||||||
|
@ -18,7 +18,7 @@
|
||||||
"lint:prettier:fix": "yarn prettier --check --write src"
|
"lint:prettier:fix": "yarn prettier --check --write src"
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
"copycat": "./bin/run"
|
"copykitku": "./bin/run"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"/bin",
|
"/bin",
|
||||||
|
@ -27,7 +27,7 @@
|
||||||
],
|
],
|
||||||
"oclif": {
|
"oclif": {
|
||||||
"commands": "./src/cli",
|
"commands": "./src/cli",
|
||||||
"bin": "copycat",
|
"bin": "copykitku",
|
||||||
"plugins": [
|
"plugins": [
|
||||||
"@oclif/plugin-help"
|
"@oclif/plugin-help"
|
||||||
]
|
]
|
||||||
|
|
|
@ -3,16 +3,16 @@ import assert from 'assert';
|
||||||
import child from 'child_process';
|
import child from 'child_process';
|
||||||
import inquirer from 'inquirer';
|
import inquirer from 'inquirer';
|
||||||
import {
|
import {
|
||||||
CopycatProfile,
|
CopykitkuProfile,
|
||||||
CopycatProfileBase,
|
CopykitkuProfileBase,
|
||||||
Vendor,
|
Vendor,
|
||||||
VENDOR_TYPE,
|
VENDOR_TYPE,
|
||||||
CopycatVendorConfig,
|
CopykitkuVendorConfig,
|
||||||
} from '../types';
|
} from '../types';
|
||||||
import { getConfig, getConfigPath, setConfig } from '../utils';
|
import { getConfig, getConfigPath, setConfig } from '../utils';
|
||||||
|
|
||||||
export default class Account extends Command {
|
export default class Account extends Command {
|
||||||
static description = 'manage accounts used by copycat';
|
static description = 'manage accounts used by copykitku';
|
||||||
|
|
||||||
static flags = {
|
static flags = {
|
||||||
help: flags.help({ char: 'h' }),
|
help: flags.help({ char: 'h' }),
|
||||||
|
@ -33,7 +33,7 @@ export default class Account extends Command {
|
||||||
|
|
||||||
static strict = true;
|
static strict = true;
|
||||||
|
|
||||||
protected getPrintableAccountInfo(account: CopycatProfile) {
|
protected getPrintableAccountInfo(account: CopykitkuProfile) {
|
||||||
return `
|
return `
|
||||||
Name:\t${account.name}
|
Name:\t${account.name}
|
||||||
Vendor:\t${account.vendor.type}
|
Vendor:\t${account.vendor.type}
|
||||||
|
@ -156,7 +156,7 @@ export default class Account extends Command {
|
||||||
token: answers.token,
|
token: answers.token,
|
||||||
},
|
},
|
||||||
name: answers.name,
|
name: answers.name,
|
||||||
} as CopycatProfile);
|
} as CopykitkuProfile);
|
||||||
|
|
||||||
setConfig(config);
|
setConfig(config);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { Command, flags } from '@oclif/command';
|
import { Command, flags } from '@oclif/command';
|
||||||
import assert from 'assert';
|
import assert from 'assert';
|
||||||
import Copycat from '../copycat';
|
import Copykitku from '../copykitku';
|
||||||
import { ENTITY_TYPE } from '../types';
|
import { ENTITY_TYPE } from '../types';
|
||||||
import { parsePath } from '../utils';
|
import { parsePath } from '../utils';
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ export default class Replicate extends Command {
|
||||||
|
|
||||||
assert(sourcePath.entity === ENTITY_TYPE.ISSUE, 'Only issues are supported now');
|
assert(sourcePath.entity === ENTITY_TYPE.ISSUE, 'Only issues are supported now');
|
||||||
|
|
||||||
const cc = new Copycat();
|
const cc = new Copykitku();
|
||||||
await cc.initialize();
|
await cc.initialize();
|
||||||
const sourceVendor = cc.vendorManagers.find((v) => v.vendor.domain === sourcePath.domain);
|
const sourceVendor = cc.vendorManagers.find((v) => v.vendor.domain === sourcePath.domain);
|
||||||
assert(sourceVendor, 'Source vendor not found in config');
|
assert(sourceVendor, 'Source vendor not found in config');
|
||||||
|
@ -33,7 +33,7 @@ export default class Replicate extends Command {
|
||||||
const sourceRepo = await sourceVendor.getRepo(sourcePath.path);
|
const sourceRepo = await sourceVendor.getRepo(sourcePath.path);
|
||||||
const destRepo = await destVendor.getRepo(destPath.path);
|
const destRepo = await destVendor.getRepo(destPath.path);
|
||||||
const sourceEntity = await sourceRepo.getIssue(sourcePath.entityID);
|
const sourceEntity = await sourceRepo.getIssue(sourcePath.entityID);
|
||||||
sourceEntity.content += `\n\nReplicated from ${sourceEntity.url} with Copycat`;
|
sourceEntity.content += `\n\nReplicated from ${sourceEntity.url} with [Copykitku](https://git.sakamoto.pl/laudompat/copykitku)`;
|
||||||
const replicatedEntity = await destRepo.replicateIssue(sourceEntity);
|
const replicatedEntity = await destRepo.replicateIssue(sourceEntity);
|
||||||
console.log(`Replicated successfully: ${replicatedEntity.url}`);
|
console.log(`Replicated successfully: ${replicatedEntity.url}`);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copycat. Copyright (C) 2020 selfisekai <laura@selfisekai.rocks> and other contributors.
|
* Copykitku. Copyright (C) 2020 selfisekai <laura@selfisekai.rocks> and other contributors.
|
||||||
*
|
*
|
||||||
* This is free software, and you are welcome to redistribute it
|
* This is free software, and you are welcome to redistribute it
|
||||||
* under the GNU General Public License 3.0 or later; see the LICENSE file for details,
|
* under the GNU General Public License 3.0 or later; see the LICENSE file for details,
|
||||||
|
@ -7,12 +7,12 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { VendorManager, CopycatConfig, CopycatProfile } from './types';
|
import { VendorManager, CopykitkuConfig, CopykitkuProfile } from './types';
|
||||||
import { getConfig, DEFAULT_CONFIG } from './utils';
|
import { getConfig, DEFAULT_CONFIG } from './utils';
|
||||||
|
|
||||||
export default class Copycat {
|
export default class Copykitku {
|
||||||
vendorManagers: VendorManager[] = [];
|
vendorManagers: VendorManager[] = [];
|
||||||
config: CopycatConfig = DEFAULT_CONFIG;
|
config: CopykitkuConfig = DEFAULT_CONFIG;
|
||||||
|
|
||||||
public async initialize() {
|
public async initialize() {
|
||||||
this.config = getConfig();
|
this.config = getConfig();
|
||||||
|
@ -23,7 +23,7 @@ export default class Copycat {
|
||||||
[
|
[
|
||||||
require(path.join(__dirname, 'vendor', profile.vendor.type, 'vendormgr')).default,
|
require(path.join(__dirname, 'vendor', profile.vendor.type, 'vendormgr')).default,
|
||||||
profile,
|
profile,
|
||||||
] as [any, CopycatProfile],
|
] as [any, CopykitkuProfile],
|
||||||
)
|
)
|
||||||
.map(([VendorMgr, vendor]) => new VendorMgr(vendor.config) as VendorManager)
|
.map(([VendorMgr, vendor]) => new VendorMgr(vendor.config) as VendorManager)
|
||||||
.map((VendorMgr) => VendorMgr.initialize()),
|
.map((VendorMgr) => VendorMgr.initialize()),
|
18
src/types.ts
18
src/types.ts
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copycat. Copyright (C) 2020 selfisekai <laura@selfisekai.rocks> and other contributors.
|
* Copykitku. Copyright (C) 2020 selfisekai <laura@selfisekai.rocks> and other contributors.
|
||||||
*
|
*
|
||||||
* This is free software, and you are welcome to redistribute it
|
* This is free software, and you are welcome to redistribute it
|
||||||
* under the GNU General Public License 3.0 or later; see the LICENSE file for details,
|
* under the GNU General Public License 3.0 or later; see the LICENSE file for details,
|
||||||
|
@ -9,30 +9,30 @@
|
||||||
import { GitHubConfig } from './vendor/github/vendormgr';
|
import { GitHubConfig } from './vendor/github/vendormgr';
|
||||||
import { GitLabConfig } from './vendor/gitlab/vendormgr';
|
import { GitLabConfig } from './vendor/gitlab/vendormgr';
|
||||||
|
|
||||||
export interface CopycatConfig {
|
export interface CopykitkuConfig {
|
||||||
vendorConfigs: CopycatProfile[];
|
vendorConfigs: CopykitkuProfile[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CopycatProfileBase {
|
export interface CopykitkuProfileBase {
|
||||||
name: string;
|
name: string;
|
||||||
vendor: Vendor<VENDOR_TYPE>;
|
vendor: Vendor<VENDOR_TYPE>;
|
||||||
/** authentication etc., always depends on vendor */
|
/** authentication etc., always depends on vendor */
|
||||||
config: CopycatVendorConfig;
|
config: CopykitkuVendorConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type CopycatVendorConfig = GitHubConfig | GitLabConfig;
|
export type CopykitkuVendorConfig = GitHubConfig | GitLabConfig;
|
||||||
|
|
||||||
export interface CopycatProfileGitHub extends CopycatProfileBase {
|
export interface CopykitkuProfileGitHub extends CopykitkuProfileBase {
|
||||||
vendor: Vendor<VENDOR_TYPE.GITHUB>;
|
vendor: Vendor<VENDOR_TYPE.GITHUB>;
|
||||||
config: GitHubConfig;
|
config: GitHubConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CopycatProfileGitLab extends CopycatProfileBase {
|
export interface CopykitkuProfileGitLab extends CopykitkuProfileBase {
|
||||||
vendor: Vendor<VENDOR_TYPE.GITLAB>;
|
vendor: Vendor<VENDOR_TYPE.GITLAB>;
|
||||||
config: GitLabConfig;
|
config: GitLabConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type CopycatProfile = CopycatProfileGitHub | CopycatProfileGitLab;
|
export type CopykitkuProfile = CopykitkuProfileGitHub | CopykitkuProfileGitLab;
|
||||||
|
|
||||||
/** indicates the used api */
|
/** indicates the used api */
|
||||||
export enum VENDOR_TYPE {
|
export enum VENDOR_TYPE {
|
||||||
|
|
12
src/utils.ts
12
src/utils.ts
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copycat. Copyright (C) 2020 selfisekai <laura@selfisekai.rocks> and other contributors.
|
* Copykitku. Copyright (C) 2020 selfisekai <laura@selfisekai.rocks> and other contributors.
|
||||||
*
|
*
|
||||||
* This is free software, and you are welcome to redistribute it
|
* This is free software, and you are welcome to redistribute it
|
||||||
* under the GNU General Public License 3.0 or later; see the LICENSE file for details,
|
* under the GNU General Public License 3.0 or later; see the LICENSE file for details,
|
||||||
|
@ -9,18 +9,18 @@
|
||||||
import { readFileSync, writeFileSync } from 'fs-extra';
|
import { readFileSync, writeFileSync } from 'fs-extra';
|
||||||
import toml from '@iarna/toml';
|
import toml from '@iarna/toml';
|
||||||
import appdataPath from 'appdata-path';
|
import appdataPath from 'appdata-path';
|
||||||
import { CopycatConfig, ENTITY_TYPE } from './types';
|
import { CopykitkuConfig, ENTITY_TYPE } from './types';
|
||||||
|
|
||||||
export const DEFAULT_CONFIG: CopycatConfig = {
|
export const DEFAULT_CONFIG: CopykitkuConfig = {
|
||||||
vendorConfigs: [],
|
vendorConfigs: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getConfigPath = () => appdataPath('copycat');
|
export const getConfigPath = () => appdataPath('copykitku.toml');
|
||||||
|
|
||||||
export const getConfig = () => {
|
export const getConfig = () => {
|
||||||
try {
|
try {
|
||||||
const file = readFileSync(getConfigPath());
|
const file = readFileSync(getConfigPath());
|
||||||
return (toml.parse(file.toString('utf-8')) as unknown) as CopycatConfig;
|
return (toml.parse(file.toString('utf-8')) as unknown) as CopykitkuConfig;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err.code === 'ENOENT') {
|
if (err.code === 'ENOENT') {
|
||||||
setConfig(DEFAULT_CONFIG);
|
setConfig(DEFAULT_CONFIG);
|
||||||
|
@ -29,7 +29,7 @@ export const getConfig = () => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const setConfig = (config: CopycatConfig) =>
|
export const setConfig = (config: CopykitkuConfig) =>
|
||||||
writeFileSync(getConfigPath(), toml.stringify({ ...DEFAULT_CONFIG, ...config } as any), {
|
writeFileSync(getConfigPath(), toml.stringify({ ...DEFAULT_CONFIG, ...config } as any), {
|
||||||
encoding: 'utf-8',
|
encoding: 'utf-8',
|
||||||
});
|
});
|
||||||
|
|
2
src/vendor/github/repomgr.ts
vendored
2
src/vendor/github/repomgr.ts
vendored
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copycat. Copyright (C) 2020 selfisekai <laura@selfisekai.rocks> and other contributors.
|
* Copykitku. Copyright (C) 2020 selfisekai <laura@selfisekai.rocks> and other contributors.
|
||||||
*
|
*
|
||||||
* This is free software, and you are welcome to redistribute it
|
* This is free software, and you are welcome to redistribute it
|
||||||
* under the GNU General Public License 3.0 or later; see the LICENSE file for details,
|
* under the GNU General Public License 3.0 or later; see the LICENSE file for details,
|
||||||
|
|
2
src/vendor/github/vendormgr.ts
vendored
2
src/vendor/github/vendormgr.ts
vendored
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copycat. Copyright (C) 2020 selfisekai <laura@selfisekai.rocks> and other contributors.
|
* Copykitku. Copyright (C) 2020 selfisekai <laura@selfisekai.rocks> and other contributors.
|
||||||
*
|
*
|
||||||
* This is free software, and you are welcome to redistribute it
|
* This is free software, and you are welcome to redistribute it
|
||||||
* under the GNU General Public License 3.0 or later; see the LICENSE file for details,
|
* under the GNU General Public License 3.0 or later; see the LICENSE file for details,
|
||||||
|
|
2
src/vendor/gitlab/repomgr.ts
vendored
2
src/vendor/gitlab/repomgr.ts
vendored
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copycat. Copyright (C) 2020 selfisekai <laura@selfisekai.rocks> and other contributors.
|
* Copykitku. Copyright (C) 2020 selfisekai <laura@selfisekai.rocks> and other contributors.
|
||||||
*
|
*
|
||||||
* This is free software, and you are welcome to redistribute it
|
* This is free software, and you are welcome to redistribute it
|
||||||
* under the GNU General Public License 3.0 or later; see the LICENSE file for details,
|
* under the GNU General Public License 3.0 or later; see the LICENSE file for details,
|
||||||
|
|
2
src/vendor/gitlab/vendormgr.ts
vendored
2
src/vendor/gitlab/vendormgr.ts
vendored
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copycat. Copyright (C) 2020 selfisekai <laura@selfisekai.rocks> and other contributors.
|
* Copykitku. Copyright (C) 2020 selfisekai <laura@selfisekai.rocks> and other contributors.
|
||||||
*
|
*
|
||||||
* This is free software, and you are welcome to redistribute it
|
* This is free software, and you are welcome to redistribute it
|
||||||
* under the GNU General Public License 3.0 or later; see the LICENSE file for details,
|
* under the GNU General Public License 3.0 or later; see the LICENSE file for details,
|
||||||
|
|
Loading…
Reference in a new issue