express-fix-any-js-from-base 1.2.5 → 1.2.8
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/LICENSE +21 -21
- package/README.md +70 -70
- package/bin/cli.js +11 -11
- package/bin/core/getLatestVersion.js +12 -12
- package/bin/core/loadRunner.js +8 -8
- package/bin/v1/UpdateJs/common/AlterFileForImport/checkDuplicate.js +13 -13
- package/bin/v1/UpdateJs/common/AlterFileForImport/findInsertIndex/defaultAfter/index.js +23 -23
- package/bin/v1/UpdateJs/common/AlterFileForImport/findInsertIndex/defaultAfter/modulat.js +21 -21
- package/bin/v1/UpdateJs/common/AlterFileForImport/findInsertIndex/defaultAfter/story.js +8 -8
- package/bin/v1/UpdateJs/common/AlterFileForImport/findInsertIndex/defaultBefore/index.js +23 -23
- package/bin/v1/UpdateJs/common/AlterFileForImport/findInsertIndex/defaultBefore/modulat.js +24 -24
- package/bin/v1/UpdateJs/common/AlterFileForImport/findInsertIndex/defaultBefore/story.js +8 -8
- package/bin/v1/UpdateJs/common/AlterFileForImport/findInsertIndex/index.js +16 -16
- package/bin/v1/UpdateJs/common/AlterFileForImport/index.js +79 -79
- package/bin/v1/UpdateJs/common/AlterFileForImport/showLogs/atEnd.js +9 -9
- package/bin/v1/UpdateJs/common/AlterFileForImport/showLogs/atStart.js +12 -12
- package/bin/v1/UpdateJs/common/AlterFileForImport/toInsertLineStory.js +16 -16
- package/bin/v1/UpdateJs/common/readFile.js +7 -7
- package/bin/v1/UpdateJs/common/writeFile.js +24 -24
- package/bin/v1/UpdateJs/index.js +8 -8
- package/bin/v1/start.js +6 -6
- package/bin/v2/UpdateJs/common/AlterFileForImport/checkDuplicate.js +13 -13
- package/bin/v2/UpdateJs/common/AlterFileForImport/findInsertIndex/defaultAfter/index.js +23 -23
- package/bin/v2/UpdateJs/common/AlterFileForImport/findInsertIndex/defaultAfter/modulat.js +21 -21
- package/bin/v2/UpdateJs/common/AlterFileForImport/findInsertIndex/defaultAfter/story.js +8 -8
- package/bin/v2/UpdateJs/common/AlterFileForImport/findInsertIndex/defaultBefore/index.js +30 -30
- package/bin/v2/UpdateJs/common/AlterFileForImport/findInsertIndex/defaultBefore/modulat.js +53 -53
- package/bin/v2/UpdateJs/common/AlterFileForImport/findInsertIndex/defaultBefore/story.js +8 -8
- package/bin/v2/UpdateJs/common/AlterFileForImport/findInsertIndex/index.js +19 -19
- package/bin/v2/UpdateJs/common/AlterFileForImport/index.js +85 -81
- package/bin/v2/UpdateJs/common/AlterFileForImport/showLogs/atEnd.js +9 -9
- package/bin/v2/UpdateJs/common/AlterFileForImport/showLogs/atStart.js +11 -11
- package/bin/v2/UpdateJs/common/AlterFileForImport/toInsertLineStory.js +16 -16
- package/bin/v2/UpdateJs/common/readFile.js +7 -7
- package/bin/v2/UpdateJs/common/writeFile.js +28 -28
- package/bin/v2/UpdateJs/index.js +8 -8
- package/bin/v2/start.js +6 -6
- package/index.js +13 -13
- package/package.json +37 -37
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 KeshavSoft
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to do so, subject to the
|
|
10
|
-
following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 KeshavSoft
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to do so, subject to the
|
|
10
|
+
following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
# express-fix-any-js-from-for-import 🚀
|
|
2
|
-
|
|
3
|
-
> **Idempotent & Clean Route Imports Builder. Intelligently scans, injects, and aligns routing import statements at the top of Javascript files.**
|
|
4
|
-
|
|
5
|
-
[](https://www.npmjs.com/package/express-fix-any-js-from-for-import)
|
|
6
|
-
[](LICENSE)
|
|
7
|
-
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
## 📖 The Story of the 3 Repositories
|
|
11
|
-
|
|
12
|
-
This package handles the top-level **imports** layer in our modular route-fixing ecosystem. It is designed to work in alignment with two other packages:
|
|
13
|
-
|
|
14
|
-
```mermaid
|
|
15
|
-
graph TD
|
|
16
|
-
story["express-fix-any-js-from-story<br/><b>(High-Level CLI Orchestrator)</b>"]
|
|
17
|
-
forimport["express-fix-any-js-from-for-import<br/><b>(Route Imports Fixer)</b>"]
|
|
18
|
-
consumption["express-fix-any-js-from-for-consumption<br/><b>(Route Consumption Fixer)</b>"]
|
|
19
|
-
|
|
20
|
-
story -->|Requires| forimport
|
|
21
|
-
story -->|Requires| consumption
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
1. **[express-fix-any-js-from-for-import](https://github.com/keshavsoft/express-fix-any-js-from-for-import)** *(This Repository)*: Focuses strictly on inspecting, formatting, and injecting route/router **import statements** cleanly at the top of Javascript files without duplication.
|
|
25
|
-
2. **[express-fix-any-js-from-for-consumption](https://github.com/keshavsoft/express-fix-any-js-from-for-consumption)**: Focuses strictly on inspecting, formatting, and injecting route/router **consumption lines** (`router.use(...)` or `router.post(...)`) in the body of the routes initialization block.
|
|
26
|
-
3. **[express-fix-any-js-from-story](https://github.com/keshavsoft/express-fix-any-js-from-story)**: The master orchestrator. It receives generation specifications (stories) and coordinates both the **import fixer** and the **consumption fixer** to safely build and update full routing definitions.
|
|
27
|
-
|
|
28
|
-
---
|
|
29
|
-
|
|
30
|
-
## ✨ Features
|
|
31
|
-
|
|
32
|
-
* **🔒 Strict Idempotency**: Prevents adding duplicate imports regardless of repeated builders runs.
|
|
33
|
-
* **📐 Layout Spacing**: Inserts imports cleanly at the top relative to existing ES imports or CommonJS requires.
|
|
34
|
-
* **⚡ Cascade Dependency**: Automatically triggers dependents notification builds downstream upon successful publishing.
|
|
35
|
-
|
|
36
|
-
---
|
|
37
|
-
|
|
38
|
-
## 🚀 Quick Start
|
|
39
|
-
|
|
40
|
-
### Installation
|
|
41
|
-
|
|
42
|
-
```bash
|
|
43
|
-
npm install express-fix-any-js-from-for-import
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
### Programmatic Usage
|
|
47
|
-
|
|
48
|
-
```javascript
|
|
49
|
-
import alterFileImports from 'express-fix-any-js-from-for-import';
|
|
50
|
-
|
|
51
|
-
alterFileImports({
|
|
52
|
-
jsFilePath: './routes/end-points.js',
|
|
53
|
-
toInsertLine: "import GetRoutes from './routes/GetRoutes.js';",
|
|
54
|
-
duplicationCheck: "import GetRoutes"
|
|
55
|
-
});
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
---
|
|
59
|
-
|
|
60
|
-
## 🛠[]() Developer Technical Guides
|
|
61
|
-
|
|
62
|
-
For more details on the orchestration system:
|
|
63
|
-
* [Developer Docs Home](./docs/index.html)
|
|
64
|
-
* [Orchestration CLI documentation](https://github.com/keshavsoft/express-fix-any-js-from-story)
|
|
65
|
-
|
|
66
|
-
---
|
|
67
|
-
|
|
68
|
-
## ⚖️ License
|
|
69
|
-
|
|
70
|
-
MIT License. Designed with ❤️ by [KeshavSoft](https://github.com/keshavsoft).
|
|
1
|
+
# express-fix-any-js-from-for-import 🚀
|
|
2
|
+
|
|
3
|
+
> **Idempotent & Clean Route Imports Builder. Intelligently scans, injects, and aligns routing import statements at the top of Javascript files.**
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/express-fix-any-js-from-for-import)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## 📖 The Story of the 3 Repositories
|
|
11
|
+
|
|
12
|
+
This package handles the top-level **imports** layer in our modular route-fixing ecosystem. It is designed to work in alignment with two other packages:
|
|
13
|
+
|
|
14
|
+
```mermaid
|
|
15
|
+
graph TD
|
|
16
|
+
story["express-fix-any-js-from-story<br/><b>(High-Level CLI Orchestrator)</b>"]
|
|
17
|
+
forimport["express-fix-any-js-from-for-import<br/><b>(Route Imports Fixer)</b>"]
|
|
18
|
+
consumption["express-fix-any-js-from-for-consumption<br/><b>(Route Consumption Fixer)</b>"]
|
|
19
|
+
|
|
20
|
+
story -->|Requires| forimport
|
|
21
|
+
story -->|Requires| consumption
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
1. **[express-fix-any-js-from-for-import](https://github.com/keshavsoft/express-fix-any-js-from-for-import)** *(This Repository)*: Focuses strictly on inspecting, formatting, and injecting route/router **import statements** cleanly at the top of Javascript files without duplication.
|
|
25
|
+
2. **[express-fix-any-js-from-for-consumption](https://github.com/keshavsoft/express-fix-any-js-from-for-consumption)**: Focuses strictly on inspecting, formatting, and injecting route/router **consumption lines** (`router.use(...)` or `router.post(...)`) in the body of the routes initialization block.
|
|
26
|
+
3. **[express-fix-any-js-from-story](https://github.com/keshavsoft/express-fix-any-js-from-story)**: The master orchestrator. It receives generation specifications (stories) and coordinates both the **import fixer** and the **consumption fixer** to safely build and update full routing definitions.
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## ✨ Features
|
|
31
|
+
|
|
32
|
+
* **🔒 Strict Idempotency**: Prevents adding duplicate imports regardless of repeated builders runs.
|
|
33
|
+
* **📐 Layout Spacing**: Inserts imports cleanly at the top relative to existing ES imports or CommonJS requires.
|
|
34
|
+
* **⚡ Cascade Dependency**: Automatically triggers dependents notification builds downstream upon successful publishing.
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## 🚀 Quick Start
|
|
39
|
+
|
|
40
|
+
### Installation
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
npm install express-fix-any-js-from-for-import
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Programmatic Usage
|
|
47
|
+
|
|
48
|
+
```javascript
|
|
49
|
+
import alterFileImports from 'express-fix-any-js-from-for-import';
|
|
50
|
+
|
|
51
|
+
alterFileImports({
|
|
52
|
+
jsFilePath: './routes/end-points.js',
|
|
53
|
+
toInsertLine: "import GetRoutes from './routes/GetRoutes.js';",
|
|
54
|
+
duplicationCheck: "import GetRoutes"
|
|
55
|
+
});
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## 🛠[]() Developer Technical Guides
|
|
61
|
+
|
|
62
|
+
For more details on the orchestration system:
|
|
63
|
+
* [Developer Docs Home](./docs/index.html)
|
|
64
|
+
* [Orchestration CLI documentation](https://github.com/keshavsoft/express-fix-any-js-from-story)
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## ⚖️ License
|
|
69
|
+
|
|
70
|
+
MIT License. Designed with ❤️ by [KeshavSoft](https://github.com/keshavsoft).
|
package/bin/cli.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import getLatestVersion from "./core/getLatestVersion.js";
|
|
4
|
-
import loadRunner from "./core/loadRunner.js";
|
|
5
|
-
|
|
6
|
-
const run = async ({ }) => {
|
|
7
|
-
const version = getLatestVersion();
|
|
8
|
-
const runner = await loadRunner(version);
|
|
9
|
-
await runner({});
|
|
10
|
-
};
|
|
11
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import getLatestVersion from "./core/getLatestVersion.js";
|
|
4
|
+
import loadRunner from "./core/loadRunner.js";
|
|
5
|
+
|
|
6
|
+
const run = async ({ }) => {
|
|
7
|
+
const version = getLatestVersion();
|
|
8
|
+
const runner = await loadRunner(version);
|
|
9
|
+
await runner({});
|
|
10
|
+
};
|
|
11
|
+
|
|
12
12
|
run({}).then();
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import path from "path";
|
|
3
|
-
import { fileURLToPath } from "url";
|
|
4
|
-
|
|
5
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
6
|
-
|
|
7
|
-
export default function getLatestVersion() {
|
|
8
|
-
const versions = fs.readdirSync(path.join(__dirname, ".."))
|
|
9
|
-
.filter(n => /^v\d+$/.test(n))
|
|
10
|
-
.sort((a, b) => parseInt(a.slice(1)) - parseInt(b.slice(1)));
|
|
11
|
-
|
|
12
|
-
return versions.at(-1);
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { fileURLToPath } from "url";
|
|
4
|
+
|
|
5
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
6
|
+
|
|
7
|
+
export default function getLatestVersion() {
|
|
8
|
+
const versions = fs.readdirSync(path.join(__dirname, ".."))
|
|
9
|
+
.filter(n => /^v\d+$/.test(n))
|
|
10
|
+
.sort((a, b) => parseInt(a.slice(1)) - parseInt(b.slice(1)));
|
|
11
|
+
|
|
12
|
+
return versions.at(-1);
|
|
13
13
|
};
|
package/bin/core/loadRunner.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export default async function loadRunner(version) {
|
|
2
|
-
const mod = await import(`../${version}/start.js`);
|
|
3
|
-
|
|
4
|
-
if (typeof mod.default !== "function") {
|
|
5
|
-
throw new Error(`Invalid start.js in ${version}`);
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
return mod.default;
|
|
1
|
+
export default async function loadRunner(version) {
|
|
2
|
+
const mod = await import(`../${version}/start.js`);
|
|
3
|
+
|
|
4
|
+
if (typeof mod.default !== "function") {
|
|
5
|
+
throw new Error(`Invalid start.js in ${version}`);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
return mod.default;
|
|
9
9
|
};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
const checkUseDuplicate = ({ inSearchText, inFileContentAsStory }) => {
|
|
2
|
-
|
|
3
|
-
const found = inFileContentAsStory.find(element => {
|
|
4
|
-
return element.folderName === inSearchText;
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
return {
|
|
8
|
-
inserted: false,
|
|
9
|
-
found,
|
|
10
|
-
lineNumber: found ? found.lineNumber : null
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
|
|
1
|
+
const checkUseDuplicate = ({ inSearchText, inFileContentAsStory }) => {
|
|
2
|
+
|
|
3
|
+
const found = inFileContentAsStory.find(element => {
|
|
4
|
+
return element.folderName === inSearchText;
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
return {
|
|
8
|
+
inserted: false,
|
|
9
|
+
found,
|
|
10
|
+
lineNumber: found ? found.lineNumber : null
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
|
|
14
14
|
export default checkUseDuplicate;
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import getFromStory from "./story.js";
|
|
2
|
-
import getFromSummary from "./modulat.js";
|
|
3
|
-
|
|
4
|
-
const findInsertIndex = ({ toInsertIndex,
|
|
5
|
-
inAllLinesStory, inSummary
|
|
6
|
-
}) => {
|
|
7
|
-
|
|
8
|
-
const storyIndex = getFromStory(inAllLinesStory);
|
|
9
|
-
|
|
10
|
-
if (storyIndex !== null) {
|
|
11
|
-
toInsertIndex = storyIndex;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const summaryIndex = getFromSummary(inSummary);
|
|
15
|
-
|
|
16
|
-
if (summaryIndex !== null) {
|
|
17
|
-
toInsertIndex = summaryIndex;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
return toInsertIndex;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export default findInsertIndex;
|
|
1
|
+
import getFromStory from "./story.js";
|
|
2
|
+
import getFromSummary from "./modulat.js";
|
|
3
|
+
|
|
4
|
+
const findInsertIndex = ({ toInsertIndex,
|
|
5
|
+
inAllLinesStory, inSummary
|
|
6
|
+
}) => {
|
|
7
|
+
|
|
8
|
+
const storyIndex = getFromStory(inAllLinesStory);
|
|
9
|
+
|
|
10
|
+
if (storyIndex !== null) {
|
|
11
|
+
toInsertIndex = storyIndex;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const summaryIndex = getFromSummary(inSummary);
|
|
15
|
+
|
|
16
|
+
if (summaryIndex !== null) {
|
|
17
|
+
toInsertIndex = summaryIndex;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
return toInsertIndex;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export default findInsertIndex;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
const getFromSummary = (inSummary) => {
|
|
2
|
-
let index = null;
|
|
3
|
-
|
|
4
|
-
if (inSummary?.exportSummary) {
|
|
5
|
-
const minLine = inSummary?.exportSummary?.maxLineNumber;
|
|
6
|
-
if (minLine !== Infinity && minLine !== -Infinity) {
|
|
7
|
-
index = minLine + 1;
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
if (inSummary?.consumeSummary) {
|
|
12
|
-
const minLine = inSummary?.consumeSummary?.maxLineNumber;
|
|
13
|
-
if (minLine !== Infinity && minLine !== -Infinity) {
|
|
14
|
-
index = minLine + 1;
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
return index;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export default getFromSummary;
|
|
1
|
+
const getFromSummary = (inSummary) => {
|
|
2
|
+
let index = null;
|
|
3
|
+
|
|
4
|
+
if (inSummary?.exportSummary) {
|
|
5
|
+
const minLine = inSummary?.exportSummary?.maxLineNumber;
|
|
6
|
+
if (minLine !== Infinity && minLine !== -Infinity) {
|
|
7
|
+
index = minLine + 1;
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
if (inSummary?.consumeSummary) {
|
|
12
|
+
const minLine = inSummary?.consumeSummary?.maxLineNumber;
|
|
13
|
+
if (minLine !== Infinity && minLine !== -Infinity) {
|
|
14
|
+
index = minLine + 1;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
return index;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export default getFromSummary;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const getFromStory = (inAllLinesStory) => {
|
|
2
|
-
if (Array.isArray(inAllLinesStory)) {
|
|
3
|
-
return inAllLinesStory.length - 1;
|
|
4
|
-
}
|
|
5
|
-
return null;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export default getFromStory;
|
|
1
|
+
const getFromStory = (inAllLinesStory) => {
|
|
2
|
+
if (Array.isArray(inAllLinesStory)) {
|
|
3
|
+
return inAllLinesStory.length - 1;
|
|
4
|
+
}
|
|
5
|
+
return null;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export default getFromStory;
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import getFromStory from "./story.js";
|
|
2
|
-
import getFromSummary from "./modulat.js";
|
|
3
|
-
|
|
4
|
-
const findInsertIndex = ({ toInsertIndex,
|
|
5
|
-
inAllLinesStory, inSummary, inKeyInSummary
|
|
6
|
-
}) => {
|
|
7
|
-
|
|
8
|
-
const storyIndex = getFromStory(inAllLinesStory);
|
|
9
|
-
|
|
10
|
-
if (storyIndex !== null) {
|
|
11
|
-
toInsertIndex = storyIndex;
|
|
12
|
-
};
|
|
13
|
-
// console.log("aaaaaaaa-- : ", inKeyInSummary);
|
|
14
|
-
const summaryIndex = getFromSummary({ inSummary, inKeyInSummary });
|
|
15
|
-
|
|
16
|
-
if (summaryIndex !== null) {
|
|
17
|
-
toInsertIndex = summaryIndex;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
return toInsertIndex;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export default findInsertIndex;
|
|
1
|
+
import getFromStory from "./story.js";
|
|
2
|
+
import getFromSummary from "./modulat.js";
|
|
3
|
+
|
|
4
|
+
const findInsertIndex = ({ toInsertIndex,
|
|
5
|
+
inAllLinesStory, inSummary, inKeyInSummary
|
|
6
|
+
}) => {
|
|
7
|
+
|
|
8
|
+
const storyIndex = getFromStory(inAllLinesStory);
|
|
9
|
+
|
|
10
|
+
if (storyIndex !== null) {
|
|
11
|
+
toInsertIndex = storyIndex;
|
|
12
|
+
};
|
|
13
|
+
// console.log("aaaaaaaa-- : ", inKeyInSummary);
|
|
14
|
+
const summaryIndex = getFromSummary({ inSummary, inKeyInSummary });
|
|
15
|
+
|
|
16
|
+
if (summaryIndex !== null) {
|
|
17
|
+
toInsertIndex = summaryIndex;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
return toInsertIndex;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export default findInsertIndex;
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
const startFunc = ({ inSummary, inKeyInSummary }) => {
|
|
2
|
-
let index = null;
|
|
3
|
-
let emptyBefore = false;
|
|
4
|
-
|
|
5
|
-
if (inSummary.importSummary?.lineCount === 0) {
|
|
6
|
-
|
|
7
|
-
if (inSummary.importFromNpmSummary?.lineCount === 0) {
|
|
8
|
-
index = 1;
|
|
9
|
-
} else {
|
|
10
|
-
emptyBefore = true;
|
|
11
|
-
index = inSummary.importFromNpmSummary?.maxLineNumber + 1;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
} else {
|
|
15
|
-
index = inSummary.importSummary?.minLineNumber;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
return {
|
|
19
|
-
emptyBefore,
|
|
20
|
-
index
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export default startFunc;
|
|
1
|
+
const startFunc = ({ inSummary, inKeyInSummary }) => {
|
|
2
|
+
let index = null;
|
|
3
|
+
let emptyBefore = false;
|
|
4
|
+
|
|
5
|
+
if (inSummary.importSummary?.lineCount === 0) {
|
|
6
|
+
|
|
7
|
+
if (inSummary.importFromNpmSummary?.lineCount === 0) {
|
|
8
|
+
index = 1;
|
|
9
|
+
} else {
|
|
10
|
+
emptyBefore = true;
|
|
11
|
+
index = inSummary.importFromNpmSummary?.maxLineNumber + 1;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
} else {
|
|
15
|
+
index = inSummary.importSummary?.minLineNumber;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
return {
|
|
19
|
+
emptyBefore,
|
|
20
|
+
index
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export default startFunc;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const getFromStory = (inAllLinesStory) => {
|
|
2
|
-
if (Array.isArray(inAllLinesStory)) {
|
|
3
|
-
return inAllLinesStory.length - 1;
|
|
4
|
-
}
|
|
5
|
-
return null;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export default getFromStory;
|
|
1
|
+
const getFromStory = (inAllLinesStory) => {
|
|
2
|
+
if (Array.isArray(inAllLinesStory)) {
|
|
3
|
+
return inAllLinesStory.length - 1;
|
|
4
|
+
}
|
|
5
|
+
return null;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export default getFromStory;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import defaultAfter from "./defaultAfter/index.js";
|
|
2
|
-
import defaultBefore from "./defaultBefore/index.js";
|
|
3
|
-
|
|
4
|
-
const startFunc = ({
|
|
5
|
-
inAllLinesStory, rulesJson, inSummary, inKeyInSummary,
|
|
6
|
-
}) => {
|
|
7
|
-
let toInsertIndex = 3;
|
|
8
|
-
|
|
9
|
-
if (rulesJson.toInsertRule === "defaultAfter") toInsertIndex = defaultAfter({ toInsertIndex, inAllLinesStory, inSummary });
|
|
10
|
-
|
|
11
|
-
if (rulesJson.toInsertRule === "defaultBefore") toInsertIndex = defaultBefore({ toInsertIndex, inAllLinesStory, inSummary, inKeyInSummary });
|
|
12
|
-
// console.log("aaaaaaaa--------- : ", toInsertIndex);
|
|
13
|
-
return toInsertIndex;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export default startFunc;
|
|
1
|
+
import defaultAfter from "./defaultAfter/index.js";
|
|
2
|
+
import defaultBefore from "./defaultBefore/index.js";
|
|
3
|
+
|
|
4
|
+
const startFunc = ({
|
|
5
|
+
inAllLinesStory, rulesJson, inSummary, inKeyInSummary,
|
|
6
|
+
}) => {
|
|
7
|
+
let toInsertIndex = 3;
|
|
8
|
+
|
|
9
|
+
if (rulesJson.toInsertRule === "defaultAfter") toInsertIndex = defaultAfter({ toInsertIndex, inAllLinesStory, inSummary });
|
|
10
|
+
|
|
11
|
+
if (rulesJson.toInsertRule === "defaultBefore") toInsertIndex = defaultBefore({ toInsertIndex, inAllLinesStory, inSummary, inKeyInSummary });
|
|
12
|
+
// console.log("aaaaaaaa--------- : ", toInsertIndex);
|
|
13
|
+
return toInsertIndex;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export default startFunc;
|