magic-renamer 21.0.69 → 21.0.73

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.
Files changed (33) hide show
  1. package/browser/fesm2022/magic-renamer-browser.mjs +97 -39
  2. package/browser/fesm2022/magic-renamer-browser.mjs.map +1 -1
  3. package/browser/package.json +1 -1
  4. package/browser/types/magic-renamer-browser.d.ts +8 -4
  5. package/browser-prod/fesm2022/magic-renamer-browser.mjs +98 -40
  6. package/browser-prod/fesm2022/magic-renamer-browser.mjs.map +1 -1
  7. package/browser-prod/package.json +1 -1
  8. package/browser-prod/types/magic-renamer-browser.d.ts +8 -4
  9. package/lib/build-info._auto-generated_.d.ts +1 -1
  10. package/lib/build-info._auto-generated_.js +1 -1
  11. package/lib/magic-renamer.js +3 -3
  12. package/lib/magic-renamer.js.map +1 -1
  13. package/lib/package.json +1 -1
  14. package/lib/rename-rule.d.ts +8 -4
  15. package/lib/rename-rule.js +98 -40
  16. package/lib/rename-rule.js.map +1 -1
  17. package/lib-prod/build-info._auto-generated_.d.ts +1 -1
  18. package/lib-prod/build-info._auto-generated_.js +1 -1
  19. package/lib-prod/magic-renamer.js +4 -4
  20. package/lib-prod/magic-renamer.js.map +1 -1
  21. package/lib-prod/package.json +1 -1
  22. package/lib-prod/rename-rule.d.ts +8 -4
  23. package/lib-prod/rename-rule.js +96 -38
  24. package/lib-prod/rename-rule.js.map +1 -1
  25. package/package.json +1 -1
  26. package/websql/fesm2022/magic-renamer-websql.mjs +97 -39
  27. package/websql/fesm2022/magic-renamer-websql.mjs.map +1 -1
  28. package/websql/package.json +1 -1
  29. package/websql/types/magic-renamer-websql.d.ts +8 -4
  30. package/websql-prod/fesm2022/magic-renamer-websql.mjs +98 -40
  31. package/websql-prod/fesm2022/magic-renamer-websql.mjs.map +1 -1
  32. package/websql-prod/package.json +1 -1
  33. package/websql-prod/types/magic-renamer-websql.d.ts +8 -4
@@ -1,7 +1,7 @@
1
- import { Helpers, _, UtilsString, Utils } from 'tnp-core/browser';
2
1
  import { Log, Level } from 'ng2-logger/browser';
2
+ import { Helpers, _, UtilsString, Utils } from 'tnp-core/browser';
3
3
 
4
- const log$1 = Log.create('magic-renemer', Level.__NOTHING);
4
+ const log$1 = Log.create('rename-rule', Level.WARN, Level.ERROR);
5
5
  class RenameRule {
6
6
  static from(pArgs) {
7
7
  pArgs = pArgs.replace(/\=\>/g, '->');
@@ -38,33 +38,72 @@ class RenameRule {
38
38
  return res;
39
39
  }
40
40
  includes(orgString) {
41
- return !_.isUndefined(this.combinations.find(v => {
41
+ return !_.isUndefined(this.combinationsData(true).combinationsAll.find(v => {
42
42
  const [from, to] = v;
43
43
  return orgString === to;
44
44
  }));
45
45
  }
46
- get combinations() {
46
+ combinationsData(getAll = false) {
47
47
  const thisTo = this.toWhiteSpaceReplaced;
48
48
  const thisFrom = this.fromWhiteSpaceReplaced;
49
- return [
50
- // TODO 'rs.asdasd-asd-A.'
51
- [
52
- UtilsString.kebabCaseNoSplitNumbers(thisFrom),
53
- UtilsString.kebabCaseNoSplitNumbers(thisTo),
54
- ], // my-entity => hello1-kitty
55
- [_.kebabCase(thisFrom), _.kebabCase(thisTo)], // my-entity => hello-kitty
56
- [_.camelCase(thisFrom), _.camelCase(thisTo)], // myEntity => helloKitty
57
- [_.upperFirst(_.camelCase(thisFrom)), _.upperFirst(_.camelCase(thisTo))], // MyEntity => HelloKitty
58
- [_.snakeCase(thisFrom), _.snakeCase(thisTo)], // my_entity => hello_kitty
59
- [_.snakeCase(thisFrom).toUpperCase(), _.snakeCase(thisTo).toUpperCase()], // MY_ENTITY => HELLO_KITTY
60
- [_.startCase(thisFrom), _.startCase(thisTo)], // My Entity => Hello Kitty
61
- [_.upperCase(thisFrom), _.upperCase(thisTo)], // MY ENTITY => HELLO KITTY
62
- [_.lowerCase(thisFrom), _.lowerCase(thisTo)], // my entity => hello kitty
63
- [
64
- _.camelCase(thisFrom).toLocaleLowerCase(),
65
- _.camelCase(thisTo).toLocaleLowerCase(),
66
- ], // myentity => hellokitty
67
- ];
49
+ /**
50
+ * Example: thisFrom === 'entity'; thisTo => 'entity-new'
51
+ * - we are not sure if 'entity' alone should be 'entity-new' or 'entityNew'
52
+ */
53
+ const isWeakFrom = _.kebabCase(thisFrom).split('-').length <= 1;
54
+ if (isWeakFrom && !getAll) {
55
+ return {
56
+ isWeakFrom,
57
+ combinationsInTemplate: [
58
+ [_.upperCase(thisFrom), _.snakeCase(thisTo).toUpperCase()], // ENTITY => HELLO_KITTY
59
+ [
60
+ _.upperFirst(_.camelCase(thisFrom)),
61
+ _.upperFirst(_.camelCase(thisTo)),
62
+ ], // Entity => HelloKitty
63
+ ['"' + _.camelCase(thisFrom) + '.', '"' + _.camelCase(thisTo) + '.'], // entity => helloKitty
64
+ [
65
+ UtilsString.kebabCaseNoSplitNumbers(thisFrom),
66
+ UtilsString.kebabCaseNoSplitNumbers(thisTo),
67
+ ], // entity1 => hello1-kitty
68
+ ],
69
+ combinationsInClass: [
70
+ [
71
+ _.upperFirst(_.camelCase(thisFrom)),
72
+ _.upperFirst(_.camelCase(thisTo)),
73
+ ], // Entity => HelloKitty
74
+ [_.upperCase(thisFrom), _.snakeCase(thisTo).toUpperCase()], // MY ENTITY => HELLO_KITTY
75
+ [_.camelCase(thisFrom), _.camelCase(thisTo)], // entity => helloKitty
76
+ ],
77
+ };
78
+ }
79
+ return {
80
+ isWeakFrom: false,
81
+ combinationsAll: [
82
+ // TODO 'rs.asdasd-asd-A.'
83
+ [
84
+ UtilsString.kebabCaseNoSplitNumbers(thisFrom),
85
+ UtilsString.kebabCaseNoSplitNumbers(thisTo),
86
+ ], // my-entity => hello1-kitty
87
+ [_.kebabCase(thisFrom), _.kebabCase(thisTo)], // my-entity => hello-kitty
88
+ [_.camelCase(thisFrom), _.camelCase(thisTo)], // myEntity => helloKitty
89
+ [
90
+ _.upperFirst(_.camelCase(thisFrom)),
91
+ _.upperFirst(_.camelCase(thisTo)),
92
+ ], // MyEntity => HelloKitty
93
+ [_.snakeCase(thisFrom), _.snakeCase(thisTo)], // my_entity => hello_kitty
94
+ [
95
+ _.snakeCase(thisFrom).toUpperCase(),
96
+ _.snakeCase(thisTo).toUpperCase(),
97
+ ], // MY_ENTITY => HELLO_KITTY
98
+ [_.startCase(thisFrom), _.startCase(thisTo)], // My Entity => Hello Kitty
99
+ [_.upperCase(thisFrom), _.upperCase(thisTo)], // MY ENTITY => HELLO KITTY
100
+ [_.lowerCase(thisFrom), _.lowerCase(thisTo)], // my entity => hello kitty
101
+ [
102
+ _.camelCase(thisFrom).toLocaleLowerCase(),
103
+ _.camelCase(thisTo).toLocaleLowerCase(),
104
+ ], // myentity => hellokitty
105
+ ],
106
+ };
68
107
  }
69
108
  /**
70
109
  * @param orgString input string
@@ -73,28 +112,47 @@ class RenameRule {
73
112
  replaceInString(orgString) {
74
113
  return this.replace({
75
114
  orgString,
76
- replaceallPossibliliteis: true,
115
+ replaceAllPossibilities: true,
77
116
  });
78
117
  }
79
118
  /**
80
119
  *
81
120
  * @param orgString (file name OR file content)
82
- * @param replaceallPossibliliteis when changin file notent (not name only)
83
- * @returns
121
+ * @param replaceAllPossibilities when changing file notent (not name only)
84
122
  */
85
123
  replace(options) {
86
- let { fileName, orgString, replaceallPossibliliteis } = options;
87
- replaceallPossibliliteis = !!replaceallPossibliliteis;
88
- const combinations = this.combinations;
89
- for (let index = 0; index < combinations.length; index++) {
90
- const v = combinations[index];
91
- let [from, to] = v;
92
- if (orgString.search(from) !== -1) {
93
- const regex = new RegExp(Utils.escapeStringForRegEx(from));
94
- log$1.i(`apply! "${regex.source}" to file ${fileName} => "${to}"`);
95
- orgString = orgString.replace(new RegExp(Utils.escapeStringForRegEx(from), 'g'), to);
96
- if (!replaceallPossibliliteis) {
97
- return orgString;
124
+ let { fileName, orgString, replaceAllPossibilities } = options;
125
+ replaceAllPossibilities = !!replaceAllPossibilities;
126
+ const combinationsData = this.combinationsData();
127
+ if (combinationsData.isWeakFrom) {
128
+ const lines = orgString.split('\n');
129
+ for (let lineIndex = 0; lineIndex < lines.length; lineIndex++) {
130
+ const line = lines[lineIndex];
131
+ let combinations = combinationsData.combinationsInTemplate;
132
+ if (line.includes('inject(')) {
133
+ // QUICK_FIX for component class variables
134
+ combinations = combinationsData.combinationsInClass;
135
+ }
136
+ for (let combinationIndex = 0; combinationIndex < combinations.length; combinationIndex++) {
137
+ let [from, to] = combinations[combinationIndex];
138
+ // console.log({ from, to });
139
+ lines[lineIndex] = lines[lineIndex].replace(new RegExp(Utils.escapeStringForRegEx(from), 'g'), to);
140
+ }
141
+ }
142
+ orgString = lines.join('\n');
143
+ }
144
+ else {
145
+ const combinations = combinationsData.combinationsAll;
146
+ for (let combinationIndex = 0; combinationIndex < combinations.length; combinationIndex++) {
147
+ const combination = combinations[combinationIndex];
148
+ let [from, to] = combination;
149
+ if (orgString.search(from) !== -1) {
150
+ const regex = new RegExp(Utils.escapeStringForRegEx(from));
151
+ log$1.i(`apply! "${regex.source}" to file ${fileName} => "${to}"`);
152
+ orgString = orgString.replace(new RegExp(Utils.escapeStringForRegEx(from), 'g'), to);
153
+ if (!replaceAllPossibilities) {
154
+ return orgString;
155
+ }
98
156
  }
99
157
  }
100
158
  }
@@ -105,7 +163,7 @@ class RenameRule {
105
163
  //#region imports
106
164
  /* */
107
165
  //#endregion
108
- const log = Log.create('magic-renemer', Level.__NOTHING);
166
+ const log = Log.create('magic-renemer', Level.WARN, Level.ERROR);
109
167
  class MagicRenamer {
110
168
  }
111
169
 
@@ -1 +1 @@
1
- {"version":3,"file":"magic-renamer-browser.mjs","sources":["../../../tmp-libs-for-dist/magic-renamer/projects/magic-renamer/src/lib/rename-rule.ts","../../../tmp-libs-for-dist/magic-renamer/projects/magic-renamer/src/lib/magic-renamer.ts","../../../tmp-libs-for-dist/magic-renamer/projects/magic-renamer/src/lib/start.ts","../../../tmp-libs-for-dist/magic-renamer/projects/magic-renamer/src/magic-renamer-browser.ts"],"sourcesContent":["import { Helpers, Utils } from 'tnp-core/browser';\nimport { _, UtilsString } from 'tnp-core/browser';\nimport { Log, Level } from 'ng2-logger/browser';\nconst log = Log.create('magic-renemer', Level.__NOTHING);\n\nexport class RenameRule {\n static from(pArgs: string): RenameRule[] {\n pArgs = pArgs.replace(/\\=\\>/g, '->');\n let args = pArgs.split(/(\\'|\\\")(\\ )+(\\'|\\\")/).filter(f => !!f) as string[];\n log.d('---- Rules ----');\n args.forEach(a => {\n log.d(a);\n });\n log.d('---------------');\n return args\n .filter(a => a.search('->') !== -1)\n .map(a => {\n const [from, to] = a.split('->');\n if (!from || !to) {\n Helpers.error(\n `Incorrect rule\n \"${from}\" -> \"${to}\"\n please follow pattern: 'test name -> my new name '`,\n false,\n true,\n );\n }\n return new RenameRule(from.trim(), to.trim());\n });\n }\n\n public readonly fromWhiteSpaceReplaced: string;\n public readonly toWhiteSpaceReplaced: string;\n constructor(\n public readonly from: string,\n public readonly to: string,\n ) {\n this.fromWhiteSpaceReplaced = from.trim().toLowerCase().replace(/\\W/g, ' ');\n this.toWhiteSpaceReplaced = to.trim().toLowerCase().replace(/\\W/g, ' ');\n }\n\n applyTo(s: string): boolean {\n s = s.trim().toLowerCase().replace(/\\W/g, '');\n const res = s.search(this.from.replace(/\\W/g, '')) !== -1;\n return res;\n }\n\n toString = () => {\n return `${this.from} => ${this.to}`;\n };\n\n includes(orgString) {\n return !_.isUndefined(\n this.combinations.find(v => {\n const [from, to] = v;\n return orgString === to;\n }),\n );\n }\n\n get combinations() {\n const thisTo = this.toWhiteSpaceReplaced;\n const thisFrom = this.fromWhiteSpaceReplaced;\n return [\n // TODO 'rs.asdasd-asd-A.'\n [\n UtilsString.kebabCaseNoSplitNumbers(thisFrom),\n UtilsString.kebabCaseNoSplitNumbers(thisTo),\n ], // my-entity => hello1-kitty\n [_.kebabCase(thisFrom), _.kebabCase(thisTo)], // my-entity => hello-kitty\n [_.camelCase(thisFrom), _.camelCase(thisTo)], // myEntity => helloKitty\n [_.upperFirst(_.camelCase(thisFrom)), _.upperFirst(_.camelCase(thisTo))], // MyEntity => HelloKitty\n [_.snakeCase(thisFrom), _.snakeCase(thisTo)], // my_entity => hello_kitty\n [_.snakeCase(thisFrom).toUpperCase(), _.snakeCase(thisTo).toUpperCase()], // MY_ENTITY => HELLO_KITTY\n [_.startCase(thisFrom), _.startCase(thisTo)], // My Entity => Hello Kitty\n [_.upperCase(thisFrom), _.upperCase(thisTo)], // MY ENTITY => HELLO KITTY\n [_.lowerCase(thisFrom), _.lowerCase(thisTo)], // my entity => hello kitty\n [\n _.camelCase(thisFrom).toLocaleLowerCase(),\n _.camelCase(thisTo).toLocaleLowerCase(),\n ], // myentity => hellokitty\n ];\n }\n\n /**\n * @param orgString input string\n * @returns string with all possible combinations replaced\n */\n replaceInString(orgString: string): string {\n return this.replace({\n orgString,\n replaceallPossibliliteis: true,\n });\n }\n\n /**\n *\n * @param orgString (file name OR file content)\n * @param replaceallPossibliliteis when changin file notent (not name only)\n * @returns\n */\n replace(options: {\n /**\n * file name for debugging\n */\n fileName?: string;\n orgString: string;\n replaceallPossibliliteis?: boolean;\n }) {\n let { fileName, orgString, replaceallPossibliliteis } = options;\n replaceallPossibliliteis = !!replaceallPossibliliteis;\n const combinations = this.combinations;\n for (let index = 0; index < combinations.length; index++) {\n const v = combinations[index];\n let [from, to] = v;\n if (orgString.search(from) !== -1) {\n const regex = new RegExp(Utils.escapeStringForRegEx(from));\n log.i(`apply! \"${regex.source}\" to file ${fileName} => \"${to}\"`);\n orgString = orgString.replace(\n new RegExp(Utils.escapeStringForRegEx(from), 'g'),\n to,\n );\n if (!replaceallPossibliliteis) {\n return orgString;\n }\n }\n }\n return orgString;\n }\n}","//#region imports\n/* */ \nimport { Log, Level } from 'ng2-logger/browser';\nimport {\n _,\n path,\n fse,\n glob,\n crossPlatformPath,\n fg,\n Utils,\n dotTaonFolder,\n dotTnpFolder,\n UtilsFilesFoldersSync,\n UtilsFilesFolders,\n} from 'tnp-core/browser';\nimport { Helpers } from 'tnp-core/browser';\n\nimport { shouldDebug } from './magic-renamer-data';\nimport { RenameRule } from './rename-rule';\n\n//#endregion\nconst log = Log.create('magic-renemer', Level.__NOTHING);\n\nexport class MagicRenamer {\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n \n}","import { MagicRenamer } from './magic-renamer';\n\nexport async function start(argsv: string[]): Promise<void> {\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n return (void 0);\n}","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["log"],"mappings":";;;AAGA,MAAMA,KAAG,GAAG,GAAG,CAAC,MAAM,CAAC,eAAe,EAAE,KAAK,CAAC,SAAS,CAAC;MAE3C,UAAU,CAAA;IACrB,OAAO,IAAI,CAAC,KAAa,EAAA;QACvB,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC;AACpC,QAAA,IAAI,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAa;AAC1E,QAAAA,KAAG,CAAC,CAAC,CAAC,iBAAiB,CAAC;AACxB,QAAA,IAAI,CAAC,OAAO,CAAC,CAAC,IAAG;AACf,YAAAA,KAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AACV,QAAA,CAAC,CAAC;AACF,QAAAA,KAAG,CAAC,CAAC,CAAC,iBAAiB,CAAC;AACxB,QAAA,OAAO;AACJ,aAAA,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aACjC,GAAG,CAAC,CAAC,IAAG;AACP,YAAA,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC;AAChC,YAAA,IAAI,CAAC,IAAI,IAAI,CAAC,EAAE,EAAE;gBAChB,OAAO,CAAC,KAAK,CACX,CAAA;AACD,SAAA,EAAA,IAAI,SAAS,EAAE,CAAA;AACiC,0DA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gBAClB;YACF;QACF;AACA,QAAA,OAAO,SAAS;IAClB;AACD;;ACjID;AACA;AAoBA;AACA,MAAM,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,eAAe,EAAE,KAAK,CAAC,SAAS,CAAC;MAE3C,YAAY,CAAA;AAiNxB;;ACvOM,eAAe,KAAK,CAAC,KAAe,EAAA;;;;;;;;;AASzC,IAAA,QAAQ,KAAK,CAAC;AAChB;;ACZA;;AAEG;;;;"}
1
+ {"version":3,"file":"magic-renamer-browser.mjs","sources":["../../../tmp-libs-for-dist/magic-renamer/projects/magic-renamer/src/lib/rename-rule.ts","../../../tmp-libs-for-dist/magic-renamer/projects/magic-renamer/src/lib/magic-renamer.ts","../../../tmp-libs-for-dist/magic-renamer/projects/magic-renamer/src/lib/start.ts","../../../tmp-libs-for-dist/magic-renamer/projects/magic-renamer/src/magic-renamer-browser.ts"],"sourcesContent":["import { Log, Level } from 'ng2-logger/browser';\nimport { Helpers, Utils } from 'tnp-core/browser';\nimport { _, UtilsString } from 'tnp-core/browser';\nconst log = Log.create('rename-rule', Level.WARN, Level.ERROR);\n\nexport class RenameRule {\n static from(pArgs: string): RenameRule[] {\n pArgs = pArgs.replace(/\\=\\>/g, '->');\n let args = pArgs.split(/(\\'|\\\")(\\ )+(\\'|\\\")/).filter(f => !!f) as string[];\n log.d('---- Rules ----');\n args.forEach(a => {\n log.d(a);\n });\n log.d('---------------');\n return args\n .filter(a => a.search('->') !== -1)\n .map(a => {\n const [from, to] = a.split('->');\n if (!from || !to) {\n Helpers.error(\n `Incorrect rule\n \"${from}\" -> \"${to}\"\n please follow pattern: 'test name -> my new name '`,\n false,\n true,\n );\n }\n return new RenameRule(from.trim(), to.trim());\n });\n }\n\n public readonly fromWhiteSpaceReplaced: string;\n\n public readonly toWhiteSpaceReplaced: string;\n\n constructor(\n public readonly from: string,\n public readonly to: string,\n ) {\n this.fromWhiteSpaceReplaced = from.trim().toLowerCase().replace(/\\W/g, ' ');\n this.toWhiteSpaceReplaced = to.trim().toLowerCase().replace(/\\W/g, ' ');\n }\n\n applyTo(s: string): boolean {\n s = s.trim().toLowerCase().replace(/\\W/g, '');\n const res = s.search(this.from.replace(/\\W/g, '')) !== -1;\n return res;\n }\n\n toString = () => {\n return `${this.from} => ${this.to}`;\n };\n\n includes(orgString) {\n return !_.isUndefined(\n this.combinationsData(true).combinationsAll.find(v => {\n const [from, to] = v;\n return orgString === to;\n }),\n );\n }\n\n combinationsData(getAll = false): {\n isWeakFrom: boolean;\n combinationsAll?: string[][];\n combinationsInClass?: string[][];\n combinationsInTemplate?: string[][];\n } {\n const thisTo = this.toWhiteSpaceReplaced;\n const thisFrom = this.fromWhiteSpaceReplaced;\n\n /**\n * Example: thisFrom === 'entity'; thisTo => 'entity-new'\n * - we are not sure if 'entity' alone should be 'entity-new' or 'entityNew'\n */\n const isWeakFrom = _.kebabCase(thisFrom).split('-').length <= 1;\n\n if (isWeakFrom && !getAll) {\n return {\n isWeakFrom,\n combinationsInTemplate: [\n [_.upperCase(thisFrom), _.snakeCase(thisTo).toUpperCase()], // ENTITY => HELLO_KITTY\n [\n _.upperFirst(_.camelCase(thisFrom)),\n _.upperFirst(_.camelCase(thisTo)),\n ], // Entity => HelloKitty\n ['\"' + _.camelCase(thisFrom) + '.', '\"' + _.camelCase(thisTo) + '.'], // entity => helloKitty\n [\n UtilsString.kebabCaseNoSplitNumbers(thisFrom),\n UtilsString.kebabCaseNoSplitNumbers(thisTo),\n ], // entity1 => hello1-kitty\n ],\n combinationsInClass: [\n [\n _.upperFirst(_.camelCase(thisFrom)),\n _.upperFirst(_.camelCase(thisTo)),\n ], // Entity => HelloKitty\n [_.upperCase(thisFrom), _.snakeCase(thisTo).toUpperCase()], // MY ENTITY => HELLO_KITTY\n [_.camelCase(thisFrom), _.camelCase(thisTo)], // entity => helloKitty\n ],\n };\n }\n return {\n isWeakFrom: false,\n combinationsAll: [\n // TODO 'rs.asdasd-asd-A.'\n [\n UtilsString.kebabCaseNoSplitNumbers(thisFrom),\n UtilsString.kebabCaseNoSplitNumbers(thisTo),\n ], // my-entity => hello1-kitty\n [_.kebabCase(thisFrom), _.kebabCase(thisTo)], // my-entity => hello-kitty\n [_.camelCase(thisFrom), _.camelCase(thisTo)], // myEntity => helloKitty\n [\n _.upperFirst(_.camelCase(thisFrom)),\n _.upperFirst(_.camelCase(thisTo)),\n ], // MyEntity => HelloKitty\n [_.snakeCase(thisFrom), _.snakeCase(thisTo)], // my_entity => hello_kitty\n [\n _.snakeCase(thisFrom).toUpperCase(),\n _.snakeCase(thisTo).toUpperCase(),\n ], // MY_ENTITY => HELLO_KITTY\n [_.startCase(thisFrom), _.startCase(thisTo)], // My Entity => Hello Kitty\n [_.upperCase(thisFrom), _.upperCase(thisTo)], // MY ENTITY => HELLO KITTY\n [_.lowerCase(thisFrom), _.lowerCase(thisTo)], // my entity => hello kitty\n [\n _.camelCase(thisFrom).toLocaleLowerCase(),\n _.camelCase(thisTo).toLocaleLowerCase(),\n ], // myentity => hellokitty\n ],\n };\n }\n\n /**\n * @param orgString input string\n * @returns string with all possible combinations replaced\n */\n replaceInString(orgString: string): string {\n return this.replace({\n orgString,\n replaceAllPossibilities: true,\n });\n }\n\n /**\n *\n * @param orgString (file name OR file content)\n * @param replaceAllPossibilities when changing file notent (not name only)\n */\n replace(options: {\n /**\n * file name for debugging\n */\n fileName?: string;\n orgString: string;\n replaceAllPossibilities?: boolean;\n }) {\n let { fileName, orgString, replaceAllPossibilities } = options;\n replaceAllPossibilities = !!replaceAllPossibilities;\n const combinationsData = this.combinationsData();\n if (combinationsData.isWeakFrom) {\n const lines = orgString.split('\\n');\n for (let lineIndex = 0; lineIndex < lines.length; lineIndex++) {\n const line = lines[lineIndex];\n\n let combinations = combinationsData.combinationsInTemplate;\n if (line.includes('inject(')) {\n // QUICK_FIX for component class variables\n combinations = combinationsData.combinationsInClass;\n }\n\n for (\n let combinationIndex = 0;\n combinationIndex < combinations.length;\n combinationIndex++\n ) {\n let [from, to] = combinations[combinationIndex];\n // console.log({ from, to });\n\n lines[lineIndex] = lines[lineIndex].replace(\n new RegExp(Utils.escapeStringForRegEx(from), 'g'),\n to,\n );\n }\n }\n orgString = lines.join('\\n');\n } else {\n const combinations = combinationsData.combinationsAll;\n for (\n let combinationIndex = 0;\n combinationIndex < combinations.length;\n combinationIndex++\n ) {\n const combination = combinations[combinationIndex];\n let [from, to] = combination;\n if (orgString.search(from) !== -1) {\n const regex = new RegExp(Utils.escapeStringForRegEx(from));\n log.i(`apply! \"${regex.source}\" to file ${fileName} => \"${to}\"`);\n orgString = orgString.replace(\n new RegExp(Utils.escapeStringForRegEx(from), 'g'),\n to,\n );\n\n if (!replaceAllPossibilities) {\n return orgString;\n }\n }\n }\n }\n\n return orgString;\n }\n}","//#region imports\n/* */ \nimport { Log, Level } from 'ng2-logger/browser';\nimport {\n _,\n path,\n fse,\n glob,\n crossPlatformPath,\n fg,\n Utils,\n dotTaonFolder,\n dotTnpFolder,\n UtilsFilesFoldersSync,\n UtilsFilesFolders,\n} from 'tnp-core/browser';\nimport { Helpers } from 'tnp-core/browser';\n\nimport { shouldDebug } from './magic-renamer-data';\nimport { RenameRule } from './rename-rule';\n\n//#endregion\nconst log = Log.create('magic-renemer', Level.WARN, Level.ERROR);\n\nexport class MagicRenamer {\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n \n}","import { MagicRenamer } from './magic-renamer';\n\nexport async function start(argsv: string[]): Promise<void> {\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n/* */\n return (void 0);\n}","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["log"],"mappings":";;;AAGA,MAAMA,KAAG,GAAG,GAAG,CAAC,MAAM,CAAC,aAAa,EAAE,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC;MAEjD,UAAU,CAAA;IACrB,OAAO,IAAI,CAAC,KAAa,EAAA;QACvB,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE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gBAAgB,EAAE,EAClB;AACA,gBAAA,MAAM,WAAW,GAAG,YAAY,CAAC,gBAAgB,CAAC;AAClD,gBAAA,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,WAAW;gBAC5B,IAAI,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE;AACjC,oBAAA,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,KAAK,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC;AAC1D,oBAAAA,KAAG,CAAC,CAAC,CAAC,CAAA,QAAA,EAAW,KAAK,CAAC,MAAM,CAAA,UAAA,EAAa,QAAQ,CAAA,KAAA,EAAQ,EAAE,CAAA,CAAA,CAAG,CAAC;oBAChE,SAAS,GAAG,SAAS,CAAC,OAAO,CAC3B,IAAI,MAAM,CAAC,KAAK,CAAC,oBAAoB,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,EACjD,EAAE,CACH;oBAED,IAAI,CAAC,uBAAuB,EAAE;AAC5B,wBAAA,OAAO,SAAS;oBAClB;gBACF;YACF;QACF;AAEA,QAAA,OAAO,SAAS;IAClB;AACD;;ACnND;AACA;AAoBA;AACA,MAAM,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,eAAe,EAAE,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC;MAEnD,YAAY,CAAA;AAqNxB;;AC3OM,eAAe,KAAK,CAAC,KAAe,EAAA;;;;;;;;;AASzC,IAAA,QAAQ,KAAK,CAAC;AAChB;;ACZA;;AAEG;;;;"}
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "magic-renamer/browser",
3
- "version": "21.0.69",
3
+ "version": "21.0.73",
4
4
  "peerDependencies": {
5
5
  "@angular/common": "^21.0.0",
6
6
  "@angular/core": "^21.0.0"
@@ -9,7 +9,12 @@ declare class RenameRule {
9
9
  applyTo(s: string): boolean;
10
10
  toString: () => string;
11
11
  includes(orgString: any): boolean;
12
- get combinations(): string[][];
12
+ combinationsData(getAll?: boolean): {
13
+ isWeakFrom: boolean;
14
+ combinationsAll?: string[][];
15
+ combinationsInClass?: string[][];
16
+ combinationsInTemplate?: string[][];
17
+ };
13
18
  /**
14
19
  * @param orgString input string
15
20
  * @returns string with all possible combinations replaced
@@ -18,8 +23,7 @@ declare class RenameRule {
18
23
  /**
19
24
  *
20
25
  * @param orgString (file name OR file content)
21
- * @param replaceallPossibliliteis when changin file notent (not name only)
22
- * @returns
26
+ * @param replaceAllPossibilities when changing file notent (not name only)
23
27
  */
24
28
  replace(options: {
25
29
  /**
@@ -27,7 +31,7 @@ declare class RenameRule {
27
31
  */
28
32
  fileName?: string;
29
33
  orgString: string;
30
- replaceallPossibliliteis?: boolean;
34
+ replaceAllPossibilities?: boolean;
31
35
  }): string;
32
36
  }
33
37
 
@@ -1,7 +1,7 @@
1
- import { Helpers__NS__error, ___NS__isUndefined, UtilsString__NS__kebabCaseNoSplitNumbers, ___NS__kebabCase, ___NS__camelCase, ___NS__upperFirst, ___NS__snakeCase, ___NS__startCase, ___NS__upperCase, ___NS__lowerCase, Utils__NS__escapeStringForRegEx } from 'tnp-core/browser-prod';
2
- import { Log, Level } from 'ng2-logger/browser-prod';
1
+ import { Log__NS__create, Level } from 'ng2-logger/browser-prod';
2
+ import { Helpers__NS__error, ___NS__isUndefined, ___NS__kebabCase, ___NS__upperFirst, ___NS__camelCase, ___NS__upperCase, ___NS__snakeCase, UtilsString__NS__kebabCaseNoSplitNumbers, ___NS__startCase, ___NS__lowerCase, Utils__NS__escapeStringForRegEx } from 'tnp-core/browser-prod';
3
3
 
4
- const log$1 = Log.create('magic-renemer', Level.__NOTHING);
4
+ const log$1 = Log__NS__create('rename-rule', Level.WARN, Level.ERROR);
5
5
  class RenameRule {
6
6
  static from(pArgs) {
7
7
  pArgs = pArgs.replace(/\=\>/g, '->');
@@ -38,33 +38,72 @@ class RenameRule {
38
38
  return res;
39
39
  }
40
40
  includes(orgString) {
41
- return !___NS__isUndefined(this.combinations.find(v => {
41
+ return !___NS__isUndefined(this.combinationsData(true).combinationsAll.find(v => {
42
42
  const [from, to] = v;
43
43
  return orgString === to;
44
44
  }));
45
45
  }
46
- get combinations() {
46
+ combinationsData(getAll = false) {
47
47
  const thisTo = this.toWhiteSpaceReplaced;
48
48
  const thisFrom = this.fromWhiteSpaceReplaced;
49
- return [
50
- // TODO 'rs.asdasd-asd-A.'
51
- [
52
- UtilsString__NS__kebabCaseNoSplitNumbers(thisFrom),
53
- UtilsString__NS__kebabCaseNoSplitNumbers(thisTo),
54
- ], // my-entity => hello1-kitty
55
- [___NS__kebabCase(thisFrom), ___NS__kebabCase(thisTo)], // my-entity => hello-kitty
56
- [___NS__camelCase(thisFrom), ___NS__camelCase(thisTo)], // myEntity => helloKitty
57
- [___NS__upperFirst(___NS__camelCase(thisFrom)), ___NS__upperFirst(___NS__camelCase(thisTo))], // MyEntity => HelloKitty
58
- [___NS__snakeCase(thisFrom), ___NS__snakeCase(thisTo)], // my_entity => hello_kitty
59
- [___NS__snakeCase(thisFrom).toUpperCase(), ___NS__snakeCase(thisTo).toUpperCase()], // MY_ENTITY => HELLO_KITTY
60
- [___NS__startCase(thisFrom), ___NS__startCase(thisTo)], // My Entity => Hello Kitty
61
- [___NS__upperCase(thisFrom), ___NS__upperCase(thisTo)], // MY ENTITY => HELLO KITTY
62
- [___NS__lowerCase(thisFrom), ___NS__lowerCase(thisTo)], // my entity => hello kitty
63
- [
64
- ___NS__camelCase(thisFrom).toLocaleLowerCase(),
65
- ___NS__camelCase(thisTo).toLocaleLowerCase(),
66
- ], // myentity => hellokitty
67
- ];
49
+ /**
50
+ * Example: thisFrom === 'entity'; thisTo => 'entity-new'
51
+ * - we are not sure if 'entity' alone should be 'entity-new' or 'entityNew'
52
+ */
53
+ const isWeakFrom = ___NS__kebabCase(thisFrom).split('-').length <= 1;
54
+ if (isWeakFrom && !getAll) {
55
+ return {
56
+ isWeakFrom,
57
+ combinationsInTemplate: [
58
+ [___NS__upperCase(thisFrom), ___NS__snakeCase(thisTo).toUpperCase()], // ENTITY => HELLO_KITTY
59
+ [
60
+ ___NS__upperFirst(___NS__camelCase(thisFrom)),
61
+ ___NS__upperFirst(___NS__camelCase(thisTo)),
62
+ ], // Entity => HelloKitty
63
+ ['"' + ___NS__camelCase(thisFrom) + '.', '"' + ___NS__camelCase(thisTo) + '.'], // entity => helloKitty
64
+ [
65
+ UtilsString__NS__kebabCaseNoSplitNumbers(thisFrom),
66
+ UtilsString__NS__kebabCaseNoSplitNumbers(thisTo),
67
+ ], // entity1 => hello1-kitty
68
+ ],
69
+ combinationsInClass: [
70
+ [
71
+ ___NS__upperFirst(___NS__camelCase(thisFrom)),
72
+ ___NS__upperFirst(___NS__camelCase(thisTo)),
73
+ ], // Entity => HelloKitty
74
+ [___NS__upperCase(thisFrom), ___NS__snakeCase(thisTo).toUpperCase()], // MY ENTITY => HELLO_KITTY
75
+ [___NS__camelCase(thisFrom), ___NS__camelCase(thisTo)], // entity => helloKitty
76
+ ],
77
+ };
78
+ }
79
+ return {
80
+ isWeakFrom: false,
81
+ combinationsAll: [
82
+ // TODO 'rs.asdasd-asd-A.'
83
+ [
84
+ UtilsString__NS__kebabCaseNoSplitNumbers(thisFrom),
85
+ UtilsString__NS__kebabCaseNoSplitNumbers(thisTo),
86
+ ], // my-entity => hello1-kitty
87
+ [___NS__kebabCase(thisFrom), ___NS__kebabCase(thisTo)], // my-entity => hello-kitty
88
+ [___NS__camelCase(thisFrom), ___NS__camelCase(thisTo)], // myEntity => helloKitty
89
+ [
90
+ ___NS__upperFirst(___NS__camelCase(thisFrom)),
91
+ ___NS__upperFirst(___NS__camelCase(thisTo)),
92
+ ], // MyEntity => HelloKitty
93
+ [___NS__snakeCase(thisFrom), ___NS__snakeCase(thisTo)], // my_entity => hello_kitty
94
+ [
95
+ ___NS__snakeCase(thisFrom).toUpperCase(),
96
+ ___NS__snakeCase(thisTo).toUpperCase(),
97
+ ], // MY_ENTITY => HELLO_KITTY
98
+ [___NS__startCase(thisFrom), ___NS__startCase(thisTo)], // My Entity => Hello Kitty
99
+ [___NS__upperCase(thisFrom), ___NS__upperCase(thisTo)], // MY ENTITY => HELLO KITTY
100
+ [___NS__lowerCase(thisFrom), ___NS__lowerCase(thisTo)], // my entity => hello kitty
101
+ [
102
+ ___NS__camelCase(thisFrom).toLocaleLowerCase(),
103
+ ___NS__camelCase(thisTo).toLocaleLowerCase(),
104
+ ], // myentity => hellokitty
105
+ ],
106
+ };
68
107
  }
69
108
  /**
70
109
  * @param orgString input string
@@ -73,28 +112,47 @@ class RenameRule {
73
112
  replaceInString(orgString) {
74
113
  return this.replace({
75
114
  orgString,
76
- replaceallPossibliliteis: true,
115
+ replaceAllPossibilities: true,
77
116
  });
78
117
  }
79
118
  /**
80
119
  *
81
120
  * @param orgString (file name OR file content)
82
- * @param replaceallPossibliliteis when changin file notent (not name only)
83
- * @returns
121
+ * @param replaceAllPossibilities when changing file notent (not name only)
84
122
  */
85
123
  replace(options) {
86
- let { fileName, orgString, replaceallPossibliliteis } = options;
87
- replaceallPossibliliteis = !!replaceallPossibliliteis;
88
- const combinations = this.combinations;
89
- for (let index = 0; index < combinations.length; index++) {
90
- const v = combinations[index];
91
- let [from, to] = v;
92
- if (orgString.search(from) !== -1) {
93
- const regex = new RegExp(Utils__NS__escapeStringForRegEx(from));
94
- log$1.i(`apply! "${regex.source}" to file ${fileName} => "${to}"`);
95
- orgString = orgString.replace(new RegExp(Utils__NS__escapeStringForRegEx(from), 'g'), to);
96
- if (!replaceallPossibliliteis) {
97
- return orgString;
124
+ let { fileName, orgString, replaceAllPossibilities } = options;
125
+ replaceAllPossibilities = !!replaceAllPossibilities;
126
+ const combinationsData = this.combinationsData();
127
+ if (combinationsData.isWeakFrom) {
128
+ const lines = orgString.split('\n');
129
+ for (let lineIndex = 0; lineIndex < lines.length; lineIndex++) {
130
+ const line = lines[lineIndex];
131
+ let combinations = combinationsData.combinationsInTemplate;
132
+ if (line.includes('inject(')) {
133
+ // QUICK_FIX for component class variables
134
+ combinations = combinationsData.combinationsInClass;
135
+ }
136
+ for (let combinationIndex = 0; combinationIndex < combinations.length; combinationIndex++) {
137
+ let [from, to] = combinations[combinationIndex];
138
+ // console.log({ from, to });
139
+ lines[lineIndex] = lines[lineIndex].replace(new RegExp(Utils__NS__escapeStringForRegEx(from), 'g'), to);
140
+ }
141
+ }
142
+ orgString = lines.join('\n');
143
+ }
144
+ else {
145
+ const combinations = combinationsData.combinationsAll;
146
+ for (let combinationIndex = 0; combinationIndex < combinations.length; combinationIndex++) {
147
+ const combination = combinations[combinationIndex];
148
+ let [from, to] = combination;
149
+ if (orgString.search(from) !== -1) {
150
+ const regex = new RegExp(Utils__NS__escapeStringForRegEx(from));
151
+ log$1.i(`apply! "${regex.source}" to file ${fileName} => "${to}"`);
152
+ orgString = orgString.replace(new RegExp(Utils__NS__escapeStringForRegEx(from), 'g'), to);
153
+ if (!replaceAllPossibilities) {
154
+ return orgString;
155
+ }
98
156
  }
99
157
  }
100
158
  }
@@ -105,7 +163,7 @@ class RenameRule {
105
163
  //#region imports
106
164
  /* */
107
165
  //#endregion
108
- const log = Log.create('magic-renemer', Level.__NOTHING);
166
+ const log = Log__NS__create('magic-renemer', Level.WARN, Level.ERROR);
109
167
  class MagicRenamer {
110
168
  }
111
169