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",
|
||||
"main": "index.js",
|
||||
"author": "selfisekai <laura@selfisekai.rocks>",
|
||||
|
@ -18,7 +18,7 @@
|
|||
"lint:prettier:fix": "yarn prettier --check --write src"
|
||||
},
|
||||
"bin": {
|
||||
"copycat": "./bin/run"
|
||||
"copykitku": "./bin/run"
|
||||
},
|
||||
"files": [
|
||||
"/bin",
|
||||
|
@ -27,7 +27,7 @@
|
|||
],
|
||||
"oclif": {
|
||||
"commands": "./src/cli",
|
||||
"bin": "copycat",
|
||||
"bin": "copykitku",
|
||||
"plugins": [
|
||||
"@oclif/plugin-help"
|
||||
]
|
||||
|
|
|
@ -3,16 +3,16 @@ import assert from 'assert';
|
|||
import child from 'child_process';
|
||||
import inquirer from 'inquirer';
|
||||
import {
|
||||
CopycatProfile,
|
||||
CopycatProfileBase,
|
||||
CopykitkuProfile,
|
||||
CopykitkuProfileBase,
|
||||
Vendor,
|
||||
VENDOR_TYPE,
|
||||
CopycatVendorConfig,
|
||||
CopykitkuVendorConfig,
|
||||
} from '../types';
|
||||
import { getConfig, getConfigPath, setConfig } from '../utils';
|
||||
|
||||
export default class Account extends Command {
|
||||
static description = 'manage accounts used by copycat';
|
||||
static description = 'manage accounts used by copykitku';
|
||||
|
||||
static flags = {
|
||||
help: flags.help({ char: 'h' }),
|
||||
|
@ -33,7 +33,7 @@ export default class Account extends Command {
|
|||
|
||||
static strict = true;
|
||||
|
||||
protected getPrintableAccountInfo(account: CopycatProfile) {
|
||||
protected getPrintableAccountInfo(account: CopykitkuProfile) {
|
||||
return `
|
||||
Name:\t${account.name}
|
||||
Vendor:\t${account.vendor.type}
|
||||
|
@ -156,7 +156,7 @@ export default class Account extends Command {
|
|||
token: answers.token,
|
||||
},
|
||||
name: answers.name,
|
||||
} as CopycatProfile);
|
||||
} as CopykitkuProfile);
|
||||
|
||||
setConfig(config);
|
||||
break;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { Command, flags } from '@oclif/command';
|
||||
import assert from 'assert';
|
||||
import Copycat from '../copycat';
|
||||
import Copykitku from '../copykitku';
|
||||
import { ENTITY_TYPE } from '../types';
|
||||
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');
|
||||
|
||||
const cc = new Copycat();
|
||||
const cc = new Copykitku();
|
||||
await cc.initialize();
|
||||
const sourceVendor = cc.vendorManagers.find((v) => v.vendor.domain === sourcePath.domain);
|
||||
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 destRepo = await destVendor.getRepo(destPath.path);
|
||||
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);
|
||||
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
|
||||
* 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 { VendorManager, CopycatConfig, CopycatProfile } from './types';
|
||||
import { VendorManager, CopykitkuConfig, CopykitkuProfile } from './types';
|
||||
import { getConfig, DEFAULT_CONFIG } from './utils';
|
||||
|
||||
export default class Copycat {
|
||||
export default class Copykitku {
|
||||
vendorManagers: VendorManager[] = [];
|
||||
config: CopycatConfig = DEFAULT_CONFIG;
|
||||
config: CopykitkuConfig = DEFAULT_CONFIG;
|
||||
|
||||
public async initialize() {
|
||||
this.config = getConfig();
|
||||
|
@ -23,7 +23,7 @@ export default class Copycat {
|
|||
[
|
||||
require(path.join(__dirname, 'vendor', profile.vendor.type, 'vendormgr')).default,
|
||||
profile,
|
||||
] as [any, CopycatProfile],
|
||||
] as [any, CopykitkuProfile],
|
||||
)
|
||||
.map(([VendorMgr, vendor]) => new VendorMgr(vendor.config) as VendorManager)
|
||||
.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
|
||||
* 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 { GitLabConfig } from './vendor/gitlab/vendormgr';
|
||||
|
||||
export interface CopycatConfig {
|
||||
vendorConfigs: CopycatProfile[];
|
||||
export interface CopykitkuConfig {
|
||||
vendorConfigs: CopykitkuProfile[];
|
||||
}
|
||||
|
||||
export interface CopycatProfileBase {
|
||||
export interface CopykitkuProfileBase {
|
||||
name: string;
|
||||
vendor: Vendor<VENDOR_TYPE>;
|
||||
/** 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>;
|
||||
config: GitHubConfig;
|
||||
}
|
||||
|
||||
export interface CopycatProfileGitLab extends CopycatProfileBase {
|
||||
export interface CopykitkuProfileGitLab extends CopykitkuProfileBase {
|
||||
vendor: Vendor<VENDOR_TYPE.GITLAB>;
|
||||
config: GitLabConfig;
|
||||
}
|
||||
|
||||
export type CopycatProfile = CopycatProfileGitHub | CopycatProfileGitLab;
|
||||
export type CopykitkuProfile = CopykitkuProfileGitHub | CopykitkuProfileGitLab;
|
||||
|
||||
/** indicates the used api */
|
||||
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
|
||||
* 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 toml from '@iarna/toml';
|
||||
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: [],
|
||||
};
|
||||
|
||||
export const getConfigPath = () => appdataPath('copycat');
|
||||
export const getConfigPath = () => appdataPath('copykitku.toml');
|
||||
|
||||
export const getConfig = () => {
|
||||
try {
|
||||
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) {
|
||||
if (err.code === 'ENOENT') {
|
||||
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), {
|
||||
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
|
||||
* 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
|
||||
* 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
|
||||
* 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
|
||||
* under the GNU General Public License 3.0 or later; see the LICENSE file for details,
|
||||
|
|
Loading…
Reference in a new issue