@neurodevs/meta-node 0.0.1 → 0.2.0
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/.vscode/tasks.json +18 -0
- package/build/__tests__/modules/NodeAutomodule.test.d.ts +20 -0
- package/build/__tests__/modules/NodeAutomodule.test.js +166 -0
- package/build/__tests__/modules/NodeAutomodule.test.js.map +1 -0
- package/build/__tests__/modules/NpmAutopackage.test.d.ts +47 -12
- package/build/__tests__/modules/NpmAutopackage.test.js +314 -34
- package/build/__tests__/modules/NpmAutopackage.test.js.map +1 -1
- package/build/index.d.ts +12 -2
- package/build/index.js +23 -6
- package/build/index.js.map +1 -1
- package/build/modules/GitAutocloner.d.ts +5 -6
- package/build/modules/GitAutocloner.js +14 -17
- package/build/modules/GitAutocloner.js.map +1 -1
- package/build/modules/NodeAutomodule.d.ts +34 -0
- package/build/modules/NodeAutomodule.js +102 -0
- package/build/modules/NodeAutomodule.js.map +1 -0
- package/build/modules/NpmAutopackage.d.ts +49 -16
- package/build/modules/NpmAutopackage.js +221 -41
- package/build/modules/NpmAutopackage.js.map +1 -1
- package/build/modules/pathExists.d.ts +1 -0
- package/build/modules/pathExists.js +14 -0
- package/build/modules/pathExists.js.map +1 -0
- package/build/scripts/runAutomodule.d.ts +1 -0
- package/build/scripts/runAutomodule.js +22 -0
- package/build/scripts/runAutomodule.js.map +1 -0
- package/build/scripts/runAutopackage.js +7 -5
- package/build/scripts/runAutopackage.js.map +1 -1
- package/build/testDoubles/Automodule/FakeAutomodule.d.ts +8 -0
- package/build/testDoubles/Automodule/FakeAutomodule.js +18 -0
- package/build/testDoubles/Automodule/FakeAutomodule.js.map +1 -0
- package/build/testDoubles/Autopackage/FakeAutopackage.d.ts +8 -0
- package/build/testDoubles/Autopackage/FakeAutopackage.js +18 -0
- package/build/testDoubles/Autopackage/FakeAutopackage.js.map +1 -0
- package/build/testDoubles/fs/fakePathExists.d.ts +3 -0
- package/build/testDoubles/fs/fakePathExists.js +13 -0
- package/build/testDoubles/fs/fakePathExists.js.map +1 -0
- package/build/testDoubles/fs/fakeWriteFile.d.ts +6 -0
- package/build/testDoubles/fs/fakeWriteFile.js +13 -0
- package/build/testDoubles/fs/fakeWriteFile.js.map +1 -0
- package/package.json +5 -1
- package/src/__tests__/modules/NodeAutomodule.test.ts +160 -0
- package/src/__tests__/modules/NpmAutopackage.test.ts +415 -33
- package/src/index.ts +24 -5
- package/src/modules/GitAutocloner.ts +18 -22
- package/src/modules/NodeAutomodule.ts +136 -0
- package/src/modules/NpmAutopackage.ts +272 -42
- package/src/modules/pathExists.ts +10 -0
- package/src/scripts/runAutomodule.ts +22 -0
- package/src/scripts/runAutopackage.ts +7 -5
- package/src/testDoubles/Automodule/FakeAutomodule.ts +19 -0
- package/src/testDoubles/Autopackage/FakeAutopackage.ts +19 -0
- package/src/testDoubles/fs/fakePathExists.ts +9 -0
- package/src/testDoubles/fs/fakeWriteFile.ts +9 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class FakeAutopackage {
|
|
4
|
+
constructor(options) {
|
|
5
|
+
FakeAutopackage.callsToConstructor.push(options);
|
|
6
|
+
}
|
|
7
|
+
async createPackage() {
|
|
8
|
+
FakeAutopackage.numCallsToCreatePackage++;
|
|
9
|
+
}
|
|
10
|
+
static resetTestDouble() {
|
|
11
|
+
this.callsToConstructor = [];
|
|
12
|
+
this.numCallsToCreatePackage = 0;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
FakeAutopackage.callsToConstructor = [];
|
|
16
|
+
FakeAutopackage.numCallsToCreatePackage = 0;
|
|
17
|
+
exports.default = FakeAutopackage;
|
|
18
|
+
//# sourceMappingURL=FakeAutopackage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FakeAutopackage.js","sourceRoot":"","sources":["../../../src/testDoubles/Autopackage/FakeAutopackage.ts"],"names":[],"mappings":";;AAEA,MAAqB,eAAe;IAIhC,YAAmB,OAA2B;QAC1C,eAAe,CAAC,kBAAkB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IACpD,CAAC;IAEM,KAAK,CAAC,aAAa;QACtB,eAAe,CAAC,uBAAuB,EAAE,CAAA;IAC7C,CAAC;IAEM,MAAM,CAAC,eAAe;QACzB,IAAI,CAAC,kBAAkB,GAAG,EAAE,CAAA;QAC5B,IAAI,CAAC,uBAAuB,GAAG,CAAC,CAAA;IACpC,CAAC;;AAda,kCAAkB,GAAyB,EAAE,CAAA;AAC7C,uCAAuB,GAAG,CAAC,CAAA;kBAFxB,eAAe"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.pathShouldExist = void 0;
|
|
4
|
+
exports.setPathShouldExist = setPathShouldExist;
|
|
5
|
+
exports.default = fakePathExists;
|
|
6
|
+
exports.pathShouldExist = {};
|
|
7
|
+
function setPathShouldExist(path, shouldExist) {
|
|
8
|
+
exports.pathShouldExist[path] = shouldExist;
|
|
9
|
+
}
|
|
10
|
+
async function fakePathExists(path) {
|
|
11
|
+
return exports.pathShouldExist[path];
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=fakePathExists.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fakePathExists.js","sourceRoot":"","sources":["../../../src/testDoubles/fs/fakePathExists.ts"],"names":[],"mappings":";;;AAEA,gDAEC;AAED,iCAEC;AARU,QAAA,eAAe,GAA4B,EAAE,CAAA;AAExD,SAAgB,kBAAkB,CAAC,IAAY,EAAE,WAAoB;IACjE,uBAAe,CAAC,IAAI,CAAC,GAAG,WAAW,CAAA;AACvC,CAAC;AAEc,KAAK,UAAU,cAAc,CAAC,IAAY;IACrD,OAAO,uBAAe,CAAC,IAAI,CAAC,CAAA;AAChC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.callsToWriteFile = void 0;
|
|
4
|
+
exports.resetCallsToWriteFile = resetCallsToWriteFile;
|
|
5
|
+
exports.default = fakeWriteFile;
|
|
6
|
+
exports.callsToWriteFile = [];
|
|
7
|
+
function resetCallsToWriteFile() {
|
|
8
|
+
exports.callsToWriteFile = [];
|
|
9
|
+
}
|
|
10
|
+
async function fakeWriteFile(file, data) {
|
|
11
|
+
exports.callsToWriteFile.push({ file, data });
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=fakeWriteFile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fakeWriteFile.js","sourceRoot":"","sources":["../../../src/testDoubles/fs/fakeWriteFile.ts"],"names":[],"mappings":";;;AAEA,sDAEC;AAED,gCAEC;AARU,QAAA,gBAAgB,GAAqC,EAAE,CAAA;AAElE,SAAgB,qBAAqB;IACjC,wBAAgB,GAAG,EAAE,CAAA;AACzB,CAAC;AAEc,KAAK,UAAU,aAAa,CAAC,IAAY,EAAE,IAAY;IAClE,wBAAgB,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAA;AACzC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neurodevs/meta-node",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Meta-layer utilities for maintaining Node.js package ecosystems.",
|
|
5
5
|
"repository": "https://github.com/neurodevs/meta-node.git",
|
|
6
6
|
"main": "build/index.js",
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"@sprucelabs/test": "^10.0.24",
|
|
33
33
|
"@sprucelabs/test-utils": "^6.0.94",
|
|
34
34
|
"@types/node": "^24.6.2",
|
|
35
|
+
"@types/node-fetch": "^2.6.13",
|
|
35
36
|
"chokidar-cli": "^3.0.0",
|
|
36
37
|
"eslint": "^9.37.0",
|
|
37
38
|
"eslint-config-spruce": "^11.2.26",
|
|
@@ -62,5 +63,8 @@
|
|
|
62
63
|
},
|
|
63
64
|
"skill": {
|
|
64
65
|
"namespace": "meta-node"
|
|
66
|
+
},
|
|
67
|
+
"dependencies": {
|
|
68
|
+
"node-fetch": "^3.3.2"
|
|
65
69
|
}
|
|
66
70
|
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { writeFile } from 'fs/promises'
|
|
2
|
+
import AbstractSpruceTest, {
|
|
3
|
+
test,
|
|
4
|
+
assert,
|
|
5
|
+
generateId,
|
|
6
|
+
} from '@sprucelabs/test-utils'
|
|
7
|
+
import NodeAutomodule, { Automodule } from '../../modules/NodeAutomodule'
|
|
8
|
+
import fakePathExists, {
|
|
9
|
+
setPathShouldExist,
|
|
10
|
+
} from '../../testDoubles/fs/fakePathExists'
|
|
11
|
+
import fakeWriteFile, {
|
|
12
|
+
callsToWriteFile,
|
|
13
|
+
resetCallsToWriteFile,
|
|
14
|
+
} from '../../testDoubles/fs/fakeWriteFile'
|
|
15
|
+
|
|
16
|
+
export default class NodeAutomoduleTest extends AbstractSpruceTest {
|
|
17
|
+
private static instance: Automodule
|
|
18
|
+
|
|
19
|
+
protected static async beforeEach() {
|
|
20
|
+
await super.beforeEach()
|
|
21
|
+
|
|
22
|
+
this.setFakePathExists()
|
|
23
|
+
this.setFakeWriteFile()
|
|
24
|
+
|
|
25
|
+
this.instance = this.NodeAutomodule()
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
@test()
|
|
29
|
+
protected static async createsInstance() {
|
|
30
|
+
assert.isTruthy(this.instance, 'Failed to create instance!')
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@test()
|
|
34
|
+
protected static async runThrowsIfTestSaveDirMissing() {
|
|
35
|
+
setPathShouldExist(this.testSaveDir, false)
|
|
36
|
+
|
|
37
|
+
const err = await assert.doesThrowAsync(async () => await this.run())
|
|
38
|
+
|
|
39
|
+
assert.isEqual(
|
|
40
|
+
err.message,
|
|
41
|
+
`testSaveDir does not exist: ${this.testSaveDir}!`,
|
|
42
|
+
'Did not receive the expected error!'
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@test()
|
|
47
|
+
protected static async runThrowsIfModuleSaveDirMissing() {
|
|
48
|
+
setPathShouldExist(this.moduleSaveDir, false)
|
|
49
|
+
|
|
50
|
+
const err = await assert.doesThrowAsync(async () => await this.run())
|
|
51
|
+
|
|
52
|
+
assert.isEqual(
|
|
53
|
+
err.message,
|
|
54
|
+
`moduleSaveDir does not exist: ${this.moduleSaveDir}!`,
|
|
55
|
+
'Did not receive the expected error!'
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
@test()
|
|
60
|
+
protected static async createsTestFileAsExpected() {
|
|
61
|
+
await this.run()
|
|
62
|
+
|
|
63
|
+
assert.isEqualDeep(
|
|
64
|
+
callsToWriteFile[0],
|
|
65
|
+
{
|
|
66
|
+
file: `${this.testSaveDir}/${this.implName}.test.ts`,
|
|
67
|
+
data: this.testFilePattern,
|
|
68
|
+
},
|
|
69
|
+
'Did not write expected test file!'
|
|
70
|
+
)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
@test()
|
|
74
|
+
protected static async createsModuleFileAsExpected() {
|
|
75
|
+
await this.run()
|
|
76
|
+
|
|
77
|
+
assert.isEqualDeep(
|
|
78
|
+
callsToWriteFile[1],
|
|
79
|
+
{
|
|
80
|
+
file: `${this.moduleSaveDir}/${this.implName}.ts`,
|
|
81
|
+
data: this.moduleFilePattern,
|
|
82
|
+
},
|
|
83
|
+
'Did not write expected module file!'
|
|
84
|
+
)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
private static async run() {
|
|
88
|
+
return await this.instance.run()
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
private static setFakePathExists() {
|
|
92
|
+
NodeAutomodule.pathExists = fakePathExists
|
|
93
|
+
|
|
94
|
+
setPathShouldExist(this.testSaveDir, true)
|
|
95
|
+
setPathShouldExist(this.moduleSaveDir, true)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
private static setFakeWriteFile() {
|
|
99
|
+
NodeAutomodule.writeFile = fakeWriteFile as typeof writeFile
|
|
100
|
+
resetCallsToWriteFile()
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
private static readonly testSaveDir = generateId()
|
|
104
|
+
private static readonly moduleSaveDir = generateId()
|
|
105
|
+
private static readonly interfaceName = generateId()
|
|
106
|
+
private static readonly implName = generateId()
|
|
107
|
+
|
|
108
|
+
private static get testFilePattern() {
|
|
109
|
+
return `
|
|
110
|
+
import AbstractSpruceTest, { test, assert } from '@sprucelabs/test-utils'
|
|
111
|
+
import ${this.implName}, { ${this.interfaceName} } from '../../modules/${this.implName}'
|
|
112
|
+
|
|
113
|
+
export default class ${this.implName}Test extends AbstractSpruceTest {
|
|
114
|
+
private static instance: ${this.interfaceName}
|
|
115
|
+
|
|
116
|
+
protected static async beforeEach() {
|
|
117
|
+
await super.beforeEach()
|
|
118
|
+
|
|
119
|
+
this.instance = this.${this.implName}()
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
@test()
|
|
123
|
+
protected static async createsInstance() {
|
|
124
|
+
assert.isTruthy(this.instance, 'Failed to create instance!')
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
private static ${this.implName}() {
|
|
128
|
+
return ${this.implName}.Create()
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
`
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
private static get moduleFilePattern() {
|
|
135
|
+
return `
|
|
136
|
+
export default class ${this.implName} implements ${this.interfaceName} {
|
|
137
|
+
public static Class?: ${this.interfaceName}Constructor
|
|
138
|
+
|
|
139
|
+
protected constructor() {}
|
|
140
|
+
|
|
141
|
+
public static Create() {
|
|
142
|
+
return new (this.Class ?? this)()
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export interface ${this.interfaceName} {}
|
|
147
|
+
|
|
148
|
+
export type ${this.interfaceName}Constructor = new () => ${this.interfaceName}
|
|
149
|
+
`
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
private static NodeAutomodule() {
|
|
153
|
+
return NodeAutomodule.Create({
|
|
154
|
+
testSaveDir: this.testSaveDir,
|
|
155
|
+
moduleSaveDir: this.moduleSaveDir,
|
|
156
|
+
interfaceName: this.interfaceName,
|
|
157
|
+
implName: this.implName,
|
|
158
|
+
})
|
|
159
|
+
}
|
|
160
|
+
}
|