@teambit/renaming 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +4 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/dist/rename.cmd.d.ts +20 -0
- package/dist/rename.cmd.js +57 -0
- package/dist/rename.cmd.js.map +1 -0
- package/dist/renaming.aspect.d.ts +2 -0
- package/dist/renaming.aspect.js +24 -0
- package/dist/renaming.aspect.js.map +1 -0
- package/dist/renaming.fragment.d.ts +16 -0
- package/dist/renaming.fragment.js +49 -0
- package/dist/renaming.fragment.js.map +1 -0
- package/dist/renaming.main.runtime.d.ts +32 -0
- package/dist/renaming.main.runtime.js +168 -0
- package/dist/renaming.main.runtime.js.map +1 -0
- package/package-tar/teambit-renaming-0.0.1.tgz +0 -0
- package/package.json +85 -0
- package/tsconfig.json +34 -0
- package/types/asset.d.ts +29 -0
- package/types/style.d.ts +42 -0
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "RenamingAspect", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _renaming().RenamingAspect;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
exports.default = void 0;
|
|
13
|
+
|
|
14
|
+
function _renaming() {
|
|
15
|
+
const data = require("./renaming.aspect");
|
|
16
|
+
|
|
17
|
+
_renaming = function () {
|
|
18
|
+
return data;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
return data;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
var _default = _renaming().RenamingAspect;
|
|
25
|
+
|
|
26
|
+
exports.default = _default;
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["index.ts"],"names":["RenamingAspect"],"mappings":";;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;eAGeA,0B","sourcesContent":["import { RenamingAspect } from './renaming.aspect';\n\nexport type { RenamingMain } from './renaming.main.runtime';\nexport default RenamingAspect;\nexport { RenamingAspect };\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Command, CommandOptions } from '@teambit/cli';
|
|
2
|
+
import { RenamingMain } from '.';
|
|
3
|
+
export declare type RenameOptions = {
|
|
4
|
+
scope?: string;
|
|
5
|
+
path?: string;
|
|
6
|
+
};
|
|
7
|
+
export declare class RenameCmd implements Command {
|
|
8
|
+
private renaming;
|
|
9
|
+
name: string;
|
|
10
|
+
description: string;
|
|
11
|
+
group: string;
|
|
12
|
+
skipWorkspace: boolean;
|
|
13
|
+
alias: string;
|
|
14
|
+
options: CommandOptions;
|
|
15
|
+
loader: boolean;
|
|
16
|
+
migration: boolean;
|
|
17
|
+
remoteOp: boolean;
|
|
18
|
+
constructor(renaming: RenamingMain);
|
|
19
|
+
report([sourceId, targetId]: [string, string], options: RenameOptions): Promise<string>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
require("core-js/modules/es.array.iterator.js");
|
|
6
|
+
|
|
7
|
+
require("core-js/modules/es.promise.js");
|
|
8
|
+
|
|
9
|
+
Object.defineProperty(exports, "__esModule", {
|
|
10
|
+
value: true
|
|
11
|
+
});
|
|
12
|
+
exports.RenameCmd = void 0;
|
|
13
|
+
|
|
14
|
+
function _defineProperty2() {
|
|
15
|
+
const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
16
|
+
|
|
17
|
+
_defineProperty2 = function () {
|
|
18
|
+
return data;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
return data;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function _chalk() {
|
|
25
|
+
const data = _interopRequireDefault(require("chalk"));
|
|
26
|
+
|
|
27
|
+
_chalk = function () {
|
|
28
|
+
return data;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
return data;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
class RenameCmd {
|
|
35
|
+
constructor(renaming) {
|
|
36
|
+
this.renaming = renaming;
|
|
37
|
+
(0, _defineProperty2().default)(this, "name", 'rename <source-id> <target-id>');
|
|
38
|
+
(0, _defineProperty2().default)(this, "description", 'EXPERIMENTAL. create a new target-component and deprecate the source-component');
|
|
39
|
+
(0, _defineProperty2().default)(this, "group", 'collaborate');
|
|
40
|
+
(0, _defineProperty2().default)(this, "skipWorkspace", true);
|
|
41
|
+
(0, _defineProperty2().default)(this, "alias", '');
|
|
42
|
+
(0, _defineProperty2().default)(this, "options", [['s', 'scope', 'default scope for the newly created component'], ['p', 'path <string>', 'relative path in the workspace. by default the path is `<scope>/<namespace>/<name>`']]);
|
|
43
|
+
(0, _defineProperty2().default)(this, "loader", true);
|
|
44
|
+
(0, _defineProperty2().default)(this, "migration", true);
|
|
45
|
+
(0, _defineProperty2().default)(this, "remoteOp", true);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async report([sourceId, targetId], options) {
|
|
49
|
+
const results = await this.renaming.rename(sourceId, targetId, options);
|
|
50
|
+
return _chalk().default.green(`successfully renamed ${_chalk().default.bold(results.sourceId.toString())} to ${_chalk().default.bold(results.targetId.toString())}`);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
exports.RenameCmd = RenameCmd;
|
|
56
|
+
|
|
57
|
+
//# sourceMappingURL=rename.cmd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["rename.cmd.ts"],"names":["RenameCmd","constructor","renaming","report","sourceId","targetId","options","results","rename","chalk","green","bold","toString"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AASO,MAAMA,SAAN,CAAmC;AAcxCC,EAAAA,WAAW,CAASC,QAAT,EAAiC;AAAA,SAAxBA,QAAwB,GAAxBA,QAAwB;AAAA,kDAbrC,gCAaqC;AAAA,yDAZ9B,gFAY8B;AAAA,mDAXpC,aAWoC;AAAA,2DAV5B,IAU4B;AAAA,mDATpC,EASoC;AAAA,qDARlC,CACR,CAAC,GAAD,EAAM,OAAN,EAAe,+CAAf,CADQ,EAER,CAAC,GAAD,EAAM,eAAN,EAAuB,qFAAvB,CAFQ,CAQkC;AAAA,oDAJnC,IAImC;AAAA,uDAHhC,IAGgC;AAAA,sDAFjC,IAEiC;AAAE;;AAElC,QAANC,MAAM,CAAC,CAACC,QAAD,EAAWC,QAAX,CAAD,EAAyCC,OAAzC,EAAkF;AAC5F,UAAMC,OAAO,GAAG,MAAM,KAAKL,QAAL,CAAcM,MAAd,CAAqBJ,QAArB,EAA+BC,QAA/B,EAAyCC,OAAzC,CAAtB;AACA,WAAOG,iBAAMC,KAAN,CACJ,wBAAuBD,iBAAME,IAAN,CAAWJ,OAAO,CAACH,QAAR,CAAiBQ,QAAjB,EAAX,CAAwC,OAAMH,iBAAME,IAAN,CAAWJ,OAAO,CAACF,QAAR,CAAiBO,QAAjB,EAAX,CAAwC,EADzG,CAAP;AAGD;;AArBuC","sourcesContent":["import chalk from 'chalk';\nimport { Command, CommandOptions } from '@teambit/cli';\nimport { RenamingMain } from '.';\n\nexport type RenameOptions = {\n scope?: string;\n path?: string;\n};\n\nexport class RenameCmd implements Command {\n name = 'rename <source-id> <target-id>';\n description = 'EXPERIMENTAL. create a new target-component and deprecate the source-component';\n group = 'collaborate';\n skipWorkspace = true;\n alias = '';\n options = [\n ['s', 'scope', 'default scope for the newly created component'],\n ['p', 'path <string>', 'relative path in the workspace. by default the path is `<scope>/<namespace>/<name>`'],\n ] as CommandOptions;\n loader = true;\n migration = true;\n remoteOp = true;\n\n constructor(private renaming: RenamingMain) {}\n\n async report([sourceId, targetId]: [string, string], options: RenameOptions): Promise<string> {\n const results = await this.renaming.rename(sourceId, targetId, options);\n return chalk.green(\n `successfully renamed ${chalk.bold(results.sourceId.toString())} to ${chalk.bold(results.targetId.toString())}`\n );\n }\n}\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.RenamingAspect = void 0;
|
|
7
|
+
|
|
8
|
+
function _harmony() {
|
|
9
|
+
const data = require("@teambit/harmony");
|
|
10
|
+
|
|
11
|
+
_harmony = function () {
|
|
12
|
+
return data;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const RenamingAspect = _harmony().Aspect.create({
|
|
19
|
+
id: 'teambit.component/renaming'
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
exports.RenamingAspect = RenamingAspect;
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=renaming.aspect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["renaming.aspect.ts"],"names":["RenamingAspect","Aspect","create","id"],"mappings":";;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEO,MAAMA,cAAc,GAAGC,kBAAOC,MAAP,CAAc;AAC1CC,EAAAA,EAAE,EAAE;AADsC,CAAd,CAAvB","sourcesContent":["import { Aspect } from '@teambit/harmony';\n\nexport const RenamingAspect = Aspect.create({\n id: 'teambit.component/renaming',\n});\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Component, ShowFragment } from '@teambit/component';
|
|
2
|
+
import { RenamingMain } from './renaming.main.runtime';
|
|
3
|
+
export declare class RenamingFragment implements ShowFragment {
|
|
4
|
+
private renaming;
|
|
5
|
+
constructor(renaming: RenamingMain);
|
|
6
|
+
title: string;
|
|
7
|
+
renderRow(component: Component): Promise<{
|
|
8
|
+
title: string;
|
|
9
|
+
content: string;
|
|
10
|
+
}>;
|
|
11
|
+
json(component: Component): Promise<{
|
|
12
|
+
title: string;
|
|
13
|
+
json: import("./renaming.main.runtime").RenamingInfo | null;
|
|
14
|
+
}>;
|
|
15
|
+
weight: number;
|
|
16
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
require("core-js/modules/es.promise.js");
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports.RenamingFragment = void 0;
|
|
11
|
+
|
|
12
|
+
function _defineProperty2() {
|
|
13
|
+
const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
14
|
+
|
|
15
|
+
_defineProperty2 = function () {
|
|
16
|
+
return data;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
return data;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
class RenamingFragment {
|
|
23
|
+
constructor(renaming) {
|
|
24
|
+
this.renaming = renaming;
|
|
25
|
+
(0, _defineProperty2().default)(this, "title", 'renaming');
|
|
26
|
+
(0, _defineProperty2().default)(this, "weight", 3);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async renderRow(component) {
|
|
30
|
+
const renamingInfo = this.renaming.getRenamingInfo(component);
|
|
31
|
+
const content = renamingInfo ? `origin: ${renamingInfo.renamedFrom.toString()}` : '';
|
|
32
|
+
return {
|
|
33
|
+
title: this.title,
|
|
34
|
+
content
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async json(component) {
|
|
39
|
+
return {
|
|
40
|
+
title: this.title,
|
|
41
|
+
json: this.renaming.getRenamingInfo(component)
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
exports.RenamingFragment = RenamingFragment;
|
|
48
|
+
|
|
49
|
+
//# sourceMappingURL=renaming.fragment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["renaming.fragment.ts"],"names":["RenamingFragment","constructor","renaming","renderRow","component","renamingInfo","getRenamingInfo","content","renamedFrom","toString","title","json"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAGO,MAAMA,gBAAN,CAA+C;AACpDC,EAAAA,WAAW,CAASC,QAAT,EAAiC;AAAA,SAAxBA,QAAwB,GAAxBA,QAAwB;AAAA,mDAEpC,UAFoC;AAAA,oDAoBnC,CApBmC;AAAE;;AAI/B,QAATC,SAAS,CAACC,SAAD,EAAuB;AACpC,UAAMC,YAAY,GAAG,KAAKH,QAAL,CAAcI,eAAd,CAA8BF,SAA9B,CAArB;AACA,UAAMG,OAAO,GAAGF,YAAY,GAAI,WAAUA,YAAY,CAACG,WAAb,CAAyBC,QAAzB,EAAoC,EAAlD,GAAsD,EAAlF;AACA,WAAO;AACLC,MAAAA,KAAK,EAAE,KAAKA,KADP;AAELH,MAAAA;AAFK,KAAP;AAID;;AAES,QAAJI,IAAI,CAACP,SAAD,EAAuB;AAC/B,WAAO;AACLM,MAAAA,KAAK,EAAE,KAAKA,KADP;AAELC,MAAAA,IAAI,EAAE,KAAKT,QAAL,CAAcI,eAAd,CAA8BF,SAA9B;AAFD,KAAP;AAID;;AAnBmD","sourcesContent":["import { Component, ShowFragment } from '@teambit/component';\nimport { RenamingMain } from './renaming.main.runtime';\n\nexport class RenamingFragment implements ShowFragment {\n constructor(private renaming: RenamingMain) {}\n\n title = 'renaming';\n\n async renderRow(component: Component) {\n const renamingInfo = this.renaming.getRenamingInfo(component);\n const content = renamingInfo ? `origin: ${renamingInfo.renamedFrom.toString()}` : '';\n return {\n title: this.title,\n content,\n };\n }\n\n async json(component: Component) {\n return {\n title: this.title,\n json: this.renaming.getRenamingInfo(component),\n };\n }\n\n weight = 3;\n}\n"]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { CLIMain } from '@teambit/cli';
|
|
2
|
+
import { Component, ComponentID, ComponentMain } from '@teambit/component';
|
|
3
|
+
import { DeprecationMain } from '@teambit/deprecation';
|
|
4
|
+
import { NewComponentHelperMain } from '@teambit/new-component-helper';
|
|
5
|
+
import { Workspace } from '@teambit/workspace';
|
|
6
|
+
import { RenameOptions } from './rename.cmd';
|
|
7
|
+
export declare class RenamingMain {
|
|
8
|
+
private workspace;
|
|
9
|
+
private newComponentHelper;
|
|
10
|
+
private deprecation;
|
|
11
|
+
constructor(workspace: Workspace, newComponentHelper: NewComponentHelperMain, deprecation: DeprecationMain);
|
|
12
|
+
rename(sourceIdStr: string, targetIdStr: string, options: RenameOptions): Promise<RenameResult>;
|
|
13
|
+
getRenamingInfo(component: Component): RenamingInfo | null;
|
|
14
|
+
private getConfig;
|
|
15
|
+
static slots: never[];
|
|
16
|
+
static dependencies: import("@teambit/harmony").Aspect[];
|
|
17
|
+
static runtime: import("@teambit/harmony").RuntimeDefinition;
|
|
18
|
+
static provider([cli, workspace, deprecation, newComponentHelper, componentMain]: [
|
|
19
|
+
CLIMain,
|
|
20
|
+
Workspace,
|
|
21
|
+
DeprecationMain,
|
|
22
|
+
NewComponentHelperMain,
|
|
23
|
+
ComponentMain
|
|
24
|
+
]): Promise<RenamingMain>;
|
|
25
|
+
}
|
|
26
|
+
export declare type RenameResult = {
|
|
27
|
+
sourceId: ComponentID;
|
|
28
|
+
targetId: ComponentID;
|
|
29
|
+
};
|
|
30
|
+
export declare type RenamingInfo = {
|
|
31
|
+
renamedFrom: ComponentID;
|
|
32
|
+
};
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
require("core-js/modules/es.array.iterator.js");
|
|
6
|
+
|
|
7
|
+
require("core-js/modules/es.promise.js");
|
|
8
|
+
|
|
9
|
+
Object.defineProperty(exports, "__esModule", {
|
|
10
|
+
value: true
|
|
11
|
+
});
|
|
12
|
+
exports.RenamingMain = void 0;
|
|
13
|
+
|
|
14
|
+
function _defineProperty2() {
|
|
15
|
+
const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
16
|
+
|
|
17
|
+
_defineProperty2 = function () {
|
|
18
|
+
return data;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
return data;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function _cli() {
|
|
25
|
+
const data = require("@teambit/cli");
|
|
26
|
+
|
|
27
|
+
_cli = function () {
|
|
28
|
+
return data;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
return data;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function _component() {
|
|
35
|
+
const data = _interopRequireWildcard(require("@teambit/component"));
|
|
36
|
+
|
|
37
|
+
_component = function () {
|
|
38
|
+
return data;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
return data;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function _deprecation() {
|
|
45
|
+
const data = require("@teambit/deprecation");
|
|
46
|
+
|
|
47
|
+
_deprecation = function () {
|
|
48
|
+
return data;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
return data;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function _newComponentHelper() {
|
|
55
|
+
const data = _interopRequireDefault(require("@teambit/new-component-helper"));
|
|
56
|
+
|
|
57
|
+
_newComponentHelper = function () {
|
|
58
|
+
return data;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
return data;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function _workspace() {
|
|
65
|
+
const data = _interopRequireDefault(require("@teambit/workspace"));
|
|
66
|
+
|
|
67
|
+
_workspace = function () {
|
|
68
|
+
return data;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
return data;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function _rename() {
|
|
75
|
+
const data = require("./rename.cmd");
|
|
76
|
+
|
|
77
|
+
_rename = function () {
|
|
78
|
+
return data;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
return data;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function _renaming() {
|
|
85
|
+
const data = require("./renaming.aspect");
|
|
86
|
+
|
|
87
|
+
_renaming = function () {
|
|
88
|
+
return data;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
return data;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function _renaming2() {
|
|
95
|
+
const data = require("./renaming.fragment");
|
|
96
|
+
|
|
97
|
+
_renaming2 = function () {
|
|
98
|
+
return data;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
return data;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
105
|
+
|
|
106
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
107
|
+
|
|
108
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
109
|
+
|
|
110
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2().default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
111
|
+
|
|
112
|
+
class RenamingMain {
|
|
113
|
+
constructor(workspace, newComponentHelper, deprecation) {
|
|
114
|
+
this.workspace = workspace;
|
|
115
|
+
this.newComponentHelper = newComponentHelper;
|
|
116
|
+
this.deprecation = deprecation;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
async rename(sourceIdStr, targetIdStr, options) {
|
|
120
|
+
const sourceId = await this.workspace.resolveComponentId(sourceIdStr);
|
|
121
|
+
const sourceComp = await this.workspace.get(sourceId);
|
|
122
|
+
const targetId = this.newComponentHelper.getNewComponentId(targetIdStr, undefined, options === null || options === void 0 ? void 0 : options.scope);
|
|
123
|
+
const targetPath = this.newComponentHelper.getNewComponentPath(targetId, options === null || options === void 0 ? void 0 : options.path);
|
|
124
|
+
const config = await this.getConfig(sourceComp);
|
|
125
|
+
await this.newComponentHelper.writeAndAddNewComp(sourceComp, targetPath, targetId, config);
|
|
126
|
+
await this.deprecation.deprecate(sourceId, targetId);
|
|
127
|
+
return {
|
|
128
|
+
sourceId,
|
|
129
|
+
targetId
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
getRenamingInfo(component) {
|
|
134
|
+
var _component$state$aspe;
|
|
135
|
+
|
|
136
|
+
const renameConfig = (_component$state$aspe = component.state.aspects.get(_renaming().RenamingAspect.id)) === null || _component$state$aspe === void 0 ? void 0 : _component$state$aspe.config;
|
|
137
|
+
if (!renameConfig) return null;
|
|
138
|
+
return {
|
|
139
|
+
renamedFrom: _component().ComponentID.fromObject(renameConfig.renamedFrom)
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
async getConfig(comp) {
|
|
144
|
+
const fromExisting = await this.newComponentHelper.getConfigFromExistingToNewComponent(comp);
|
|
145
|
+
return _objectSpread(_objectSpread({}, fromExisting), {}, {
|
|
146
|
+
[_renaming().RenamingAspect.id]: {
|
|
147
|
+
renamedFrom: comp.id.toObject()
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
static async provider([cli, workspace, deprecation, newComponentHelper, componentMain]) {
|
|
153
|
+
const renaming = new RenamingMain(workspace, newComponentHelper, deprecation);
|
|
154
|
+
cli.register(new (_rename().RenameCmd)(renaming));
|
|
155
|
+
componentMain.registerShowFragments([new (_renaming2().RenamingFragment)(renaming)]);
|
|
156
|
+
return renaming;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
exports.RenamingMain = RenamingMain;
|
|
162
|
+
(0, _defineProperty2().default)(RenamingMain, "slots", []);
|
|
163
|
+
(0, _defineProperty2().default)(RenamingMain, "dependencies", [_cli().CLIAspect, _workspace().default, _deprecation().DeprecationAspect, _newComponentHelper().default, _component().default]);
|
|
164
|
+
(0, _defineProperty2().default)(RenamingMain, "runtime", _cli().MainRuntime);
|
|
165
|
+
|
|
166
|
+
_renaming().RenamingAspect.addRuntime(RenamingMain);
|
|
167
|
+
|
|
168
|
+
//# sourceMappingURL=renaming.main.runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["renaming.main.runtime.ts"],"names":["RenamingMain","constructor","workspace","newComponentHelper","deprecation","rename","sourceIdStr","targetIdStr","options","sourceId","resolveComponentId","sourceComp","get","targetId","getNewComponentId","undefined","scope","targetPath","getNewComponentPath","path","config","getConfig","writeAndAddNewComp","deprecate","getRenamingInfo","component","renameConfig","state","aspects","RenamingAspect","id","renamedFrom","ComponentID","fromObject","comp","fromExisting","getConfigFromExistingToNewComponent","toObject","provider","cli","componentMain","renaming","register","RenameCmd","registerShowFragments","RenamingFragment","CLIAspect","WorkspaceAspect","DeprecationAspect","NewComponentHelperAspect","ComponentAspect","MainRuntime","addRuntime"],"mappings":"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","sourcesContent":["import { CLIAspect, CLIMain, MainRuntime } from '@teambit/cli';\nimport ComponentAspect, { Component, ComponentID, ComponentMain } from '@teambit/component';\nimport { DeprecationAspect, DeprecationMain } from '@teambit/deprecation';\nimport NewComponentHelperAspect, { NewComponentHelperMain } from '@teambit/new-component-helper';\nimport WorkspaceAspect, { Workspace } from '@teambit/workspace';\nimport { RenameCmd, RenameOptions } from './rename.cmd';\nimport { RenamingAspect } from './renaming.aspect';\nimport { RenamingFragment } from './renaming.fragment';\n\nexport class RenamingMain {\n constructor(\n private workspace: Workspace,\n private newComponentHelper: NewComponentHelperMain,\n private deprecation: DeprecationMain\n ) {}\n\n async rename(sourceIdStr: string, targetIdStr: string, options: RenameOptions): Promise<RenameResult> {\n const sourceId = await this.workspace.resolveComponentId(sourceIdStr);\n const sourceComp = await this.workspace.get(sourceId);\n const targetId = this.newComponentHelper.getNewComponentId(targetIdStr, undefined, options?.scope);\n const targetPath = this.newComponentHelper.getNewComponentPath(targetId, options?.path);\n const config = await this.getConfig(sourceComp);\n await this.newComponentHelper.writeAndAddNewComp(sourceComp, targetPath, targetId, config);\n await this.deprecation.deprecate(sourceId, targetId);\n\n return {\n sourceId,\n targetId,\n };\n }\n\n getRenamingInfo(component: Component): RenamingInfo | null {\n const renameConfig = component.state.aspects.get(RenamingAspect.id)?.config as RenamingInfo | undefined;\n if (!renameConfig) return null;\n return {\n renamedFrom: ComponentID.fromObject(renameConfig.renamedFrom),\n };\n }\n\n private async getConfig(comp: Component) {\n const fromExisting = await this.newComponentHelper.getConfigFromExistingToNewComponent(comp);\n return {\n ...fromExisting,\n [RenamingAspect.id]: {\n renamedFrom: comp.id.toObject(),\n },\n };\n }\n\n static slots = [];\n static dependencies = [CLIAspect, WorkspaceAspect, DeprecationAspect, NewComponentHelperAspect, ComponentAspect];\n static runtime = MainRuntime;\n static async provider([cli, workspace, deprecation, newComponentHelper, componentMain]: [\n CLIMain,\n Workspace,\n DeprecationMain,\n NewComponentHelperMain,\n ComponentMain\n ]) {\n const renaming = new RenamingMain(workspace, newComponentHelper, deprecation);\n cli.register(new RenameCmd(renaming));\n componentMain.registerShowFragments([new RenamingFragment(renaming)]);\n return renaming;\n }\n}\n\nRenamingAspect.addRuntime(RenamingMain);\n\nexport type RenameResult = { sourceId: ComponentID; targetId: ComponentID };\n\nexport type RenamingInfo = {\n renamedFrom: ComponentID;\n};\n"]}
|
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@teambit/renaming",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"componentId": {
|
|
6
|
+
"scope": "teambit.component",
|
|
7
|
+
"name": "renaming",
|
|
8
|
+
"version": "0.0.1"
|
|
9
|
+
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"chalk": "2.4.2",
|
|
12
|
+
"@teambit/harmony": "0.2.11",
|
|
13
|
+
"@babel/runtime": "7.12.18",
|
|
14
|
+
"core-js": "^3.0.0",
|
|
15
|
+
"@teambit/cli": "0.0.410",
|
|
16
|
+
"@teambit/component": "0.0.597",
|
|
17
|
+
"@teambit/deprecation": "0.0.597",
|
|
18
|
+
"@teambit/new-component-helper": "0.0.1",
|
|
19
|
+
"@teambit/workspace": "0.0.597"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@types/mocha": "5.2.7",
|
|
23
|
+
"@types/testing-library__jest-dom": "5.9.5",
|
|
24
|
+
"@types/jest": "^26.0.0",
|
|
25
|
+
"@types/react-dom": "^17.0.5",
|
|
26
|
+
"@types/react": "^17.0.8",
|
|
27
|
+
"@types/node": "12.20.4"
|
|
28
|
+
},
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"@teambit/legacy": "1.0.197",
|
|
31
|
+
"react-dom": "^16.8.0 || ^17.0.0",
|
|
32
|
+
"react": "^16.8.0 || ^17.0.0"
|
|
33
|
+
},
|
|
34
|
+
"license": "Apache-2.0",
|
|
35
|
+
"bit": {
|
|
36
|
+
"bindingPrefix": "@teambit",
|
|
37
|
+
"env": {},
|
|
38
|
+
"overrides": {
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@teambit/legacy": "-",
|
|
41
|
+
"@babel/runtime": "7.12.18",
|
|
42
|
+
"core-js": "^3.0.0",
|
|
43
|
+
"react-dom": "-",
|
|
44
|
+
"react": "-"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@teambit/legacy": "-",
|
|
48
|
+
"@types/mocha": "5.2.7",
|
|
49
|
+
"@types/testing-library__jest-dom": "5.9.5",
|
|
50
|
+
"@types/jest": "^26.0.0",
|
|
51
|
+
"@types/react-dom": "^17.0.5",
|
|
52
|
+
"@types/react": "^17.0.8",
|
|
53
|
+
"@types/node": "12.20.4",
|
|
54
|
+
"react-dom": "-",
|
|
55
|
+
"react": "-"
|
|
56
|
+
},
|
|
57
|
+
"peerDependencies": {
|
|
58
|
+
"@teambit/legacy": "1.0.197",
|
|
59
|
+
"react-dom": "^16.8.0 || ^17.0.0",
|
|
60
|
+
"react": "^16.8.0 || ^17.0.0"
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
"private": false,
|
|
65
|
+
"engines": {
|
|
66
|
+
"node": ">=12.22.0"
|
|
67
|
+
},
|
|
68
|
+
"repository": {
|
|
69
|
+
"type": "git",
|
|
70
|
+
"url": "https://github.com/teambit/bit"
|
|
71
|
+
},
|
|
72
|
+
"keywords": [
|
|
73
|
+
"bit",
|
|
74
|
+
"bit-aspect",
|
|
75
|
+
"components",
|
|
76
|
+
"collaboration",
|
|
77
|
+
"web",
|
|
78
|
+
"react",
|
|
79
|
+
"react-components",
|
|
80
|
+
"angular",
|
|
81
|
+
"angular-components",
|
|
82
|
+
"vue",
|
|
83
|
+
"vue-components"
|
|
84
|
+
]
|
|
85
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"lib": [
|
|
4
|
+
"es2019",
|
|
5
|
+
"DOM",
|
|
6
|
+
"ES6",
|
|
7
|
+
"DOM.Iterable",
|
|
8
|
+
"ScriptHost"
|
|
9
|
+
],
|
|
10
|
+
"target": "es2015",
|
|
11
|
+
"module": "commonjs",
|
|
12
|
+
"jsx": "react",
|
|
13
|
+
"declaration": true,
|
|
14
|
+
"sourceMap": true,
|
|
15
|
+
"skipLibCheck": true,
|
|
16
|
+
"moduleResolution": "node",
|
|
17
|
+
"esModuleInterop": true,
|
|
18
|
+
"resolveJsonModule": true,
|
|
19
|
+
"composite": true,
|
|
20
|
+
"emitDeclarationOnly": true,
|
|
21
|
+
"outDir": "dist",
|
|
22
|
+
"experimentalDecorators": true,
|
|
23
|
+
"emitDecoratorMetadata": true,
|
|
24
|
+
"allowSyntheticDefaultImports": true,
|
|
25
|
+
"strictPropertyInitialization": false,
|
|
26
|
+
"strict": true,
|
|
27
|
+
"noImplicitAny": false,
|
|
28
|
+
"rootDir": ".",
|
|
29
|
+
"preserveConstEnums": true
|
|
30
|
+
},
|
|
31
|
+
"exclude": [
|
|
32
|
+
"dist"
|
|
33
|
+
]
|
|
34
|
+
}
|
package/types/asset.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
declare module '*.png' {
|
|
2
|
+
const value: any;
|
|
3
|
+
export = value;
|
|
4
|
+
}
|
|
5
|
+
declare module '*.svg' {
|
|
6
|
+
import type { FunctionComponent, SVGProps } from 'react';
|
|
7
|
+
|
|
8
|
+
export const ReactComponent: FunctionComponent<SVGProps<SVGSVGElement> & { title?: string }>;
|
|
9
|
+
const src: string;
|
|
10
|
+
export default src;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// @TODO Gilad
|
|
14
|
+
declare module '*.jpg' {
|
|
15
|
+
const value: any;
|
|
16
|
+
export = value;
|
|
17
|
+
}
|
|
18
|
+
declare module '*.jpeg' {
|
|
19
|
+
const value: any;
|
|
20
|
+
export = value;
|
|
21
|
+
}
|
|
22
|
+
declare module '*.gif' {
|
|
23
|
+
const value: any;
|
|
24
|
+
export = value;
|
|
25
|
+
}
|
|
26
|
+
declare module '*.bmp' {
|
|
27
|
+
const value: any;
|
|
28
|
+
export = value;
|
|
29
|
+
}
|
package/types/style.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
declare module '*.module.css' {
|
|
2
|
+
const classes: { readonly [key: string]: string };
|
|
3
|
+
export default classes;
|
|
4
|
+
}
|
|
5
|
+
declare module '*.module.scss' {
|
|
6
|
+
const classes: { readonly [key: string]: string };
|
|
7
|
+
export default classes;
|
|
8
|
+
}
|
|
9
|
+
declare module '*.module.sass' {
|
|
10
|
+
const classes: { readonly [key: string]: string };
|
|
11
|
+
export default classes;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
declare module '*.module.less' {
|
|
15
|
+
const classes: { readonly [key: string]: string };
|
|
16
|
+
export default classes;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
declare module '*.less' {
|
|
20
|
+
const classes: { readonly [key: string]: string };
|
|
21
|
+
export default classes;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
declare module '*.css' {
|
|
25
|
+
const classes: { readonly [key: string]: string };
|
|
26
|
+
export default classes;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
declare module '*.sass' {
|
|
30
|
+
const classes: { readonly [key: string]: string };
|
|
31
|
+
export default classes;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
declare module '*.scss' {
|
|
35
|
+
const classes: { readonly [key: string]: string };
|
|
36
|
+
export default classes;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
declare module '*.mdx' {
|
|
40
|
+
const component: any;
|
|
41
|
+
export default component;
|
|
42
|
+
}
|