@neurodevs/meta-node 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.
Files changed (39) hide show
  1. package/.nvmrc +1 -0
  2. package/.vscode/launch.json +58 -0
  3. package/.vscode/settings.json +67 -0
  4. package/.vscode/tasks.json +112 -0
  5. package/LICENSE +21 -0
  6. package/README.md +2 -0
  7. package/build/.spruce/settings.json +11 -0
  8. package/build/__tests__/modules/GitAutocloner.test.d.ts +28 -0
  9. package/build/__tests__/modules/GitAutocloner.test.js +158 -0
  10. package/build/__tests__/modules/GitAutocloner.test.js.map +1 -0
  11. package/build/__tests__/modules/NpmAutopackage.test.d.ts +24 -0
  12. package/build/__tests__/modules/NpmAutopackage.test.js +136 -0
  13. package/build/__tests__/modules/NpmAutopackage.test.js.map +1 -0
  14. package/build/index.d.ts +6 -0
  15. package/build/index.js +32 -0
  16. package/build/index.js.map +1 -0
  17. package/build/modules/GitAutocloner.d.ts +38 -0
  18. package/build/modules/GitAutocloner.js +84 -0
  19. package/build/modules/GitAutocloner.js.map +1 -0
  20. package/build/modules/NpmAutopackage.d.ts +44 -0
  21. package/build/modules/NpmAutopackage.js +83 -0
  22. package/build/modules/NpmAutopackage.js.map +1 -0
  23. package/build/scripts/runAutopackage.d.ts +1 -0
  24. package/build/scripts/runAutopackage.js +26 -0
  25. package/build/scripts/runAutopackage.js.map +1 -0
  26. package/build/testDoubles/Autocloner/FakeAutocloner.d.ts +8 -0
  27. package/build/testDoubles/Autocloner/FakeAutocloner.js +18 -0
  28. package/build/testDoubles/Autocloner/FakeAutocloner.js.map +1 -0
  29. package/eslint.config.mjs +3 -0
  30. package/package.json +66 -0
  31. package/src/.spruce/settings.json +11 -0
  32. package/src/__tests__/modules/GitAutocloner.test.ts +149 -0
  33. package/src/__tests__/modules/NpmAutopackage.test.ts +124 -0
  34. package/src/index.ts +12 -0
  35. package/src/modules/GitAutocloner.ts +115 -0
  36. package/src/modules/NpmAutopackage.ts +124 -0
  37. package/src/scripts/runAutopackage.ts +25 -0
  38. package/src/testDoubles/Autocloner/FakeAutocloner.ts +19 -0
  39. package/tsconfig.json +39 -0
package/.nvmrc ADDED
@@ -0,0 +1 @@
1
+ lts/*
@@ -0,0 +1,58 @@
1
+ {
2
+ "version": "0.2.0",
3
+ "configurations": [
4
+ {
5
+ "type": "node",
6
+ "request": "attach",
7
+ "name": "attach.tests",
8
+ "port": 5200,
9
+ "restart": true,
10
+ "timeout": 10000
11
+ },
12
+ {
13
+ "type": "node",
14
+ "request": "launch",
15
+ "name": "test.file",
16
+ "runtimeExecutable": "node",
17
+ "runtimeArgs": [
18
+ "--inspect-brk",
19
+ "--trace-warnings",
20
+ "${workspaceFolder}/node_modules/.bin/jest",
21
+ "${fileBasenameNoExtension}",
22
+ "--detectOpenHandles"
23
+ ],
24
+ "cwd": "${workspaceFolder}",
25
+ "console": "integratedTerminal",
26
+ "internalConsoleOptions": "neverOpen"
27
+ },
28
+ {
29
+ "type": "node",
30
+ "request": "launch",
31
+ "name": "test.all",
32
+ "runtimeExecutable": "node",
33
+ "runtimeArgs": [
34
+ "--inspect-brk",
35
+ "--trace-warnings",
36
+ "${workspaceFolder}/node_modules/.bin/jest"
37
+ ],
38
+ "cwd": "${workspaceFolder}",
39
+ "console": "integratedTerminal",
40
+ "internalConsoleOptions": "neverOpen"
41
+ },
42
+ {
43
+ "type": "node",
44
+ "request": "launch",
45
+ "name": "boot",
46
+ "runtimeExecutable": "yarn",
47
+ "runtimeArgs": [
48
+ "run",
49
+ "--inspect-brk",
50
+ "--trace-warnings",
51
+ "boot"
52
+ ],
53
+ "cwd": "${workspaceFolder}",
54
+ "console": "integratedTerminal",
55
+ "internalConsoleOptions": "neverOpen"
56
+ }
57
+ ]
58
+ }
@@ -0,0 +1,67 @@
1
+ {
2
+ "debug.node.autoAttach": "on",
3
+ "git.ignoreLimitWarning": true,
4
+ "javascript.validate.enable": false,
5
+ "files.watcherExclude": {
6
+ "**/.git/objects/**": true,
7
+ "**/.git/subtree-cache/**": true,
8
+ "**/build/**": true,
9
+ "**/node_modules/**": true,
10
+ },
11
+ "search.exclude": {
12
+ "**/build/**": true,
13
+ "**/node_modules/**": true,
14
+ "**/.next/**": true
15
+ },
16
+ "editor.maxTokenizationLineLength": 20000000,
17
+ "[javascript]": {
18
+ "editor.formatOnSave": false
19
+ },
20
+ "[javascriptreact]": {
21
+ "editor.formatOnSave": false
22
+ },
23
+ "[typescript]": {
24
+ "editor.formatOnSave": false
25
+ },
26
+ "[typescriptreact]": {
27
+ "editor.formatOnSave": false
28
+ },
29
+ "[handlebars]": {
30
+ "editor.formatOnSave": false
31
+ },
32
+ "typescript.tsdk": "node_modules/typescript/lib",
33
+ "cSpell.ignorePaths": [
34
+ "**/package-lock.json",
35
+ "**/node_modules/**",
36
+ "**/build/**",
37
+ "**/vscode-extension/**",
38
+ "**/.git/objects/**",
39
+ ".vscode",
40
+ ".spruce"
41
+ ],
42
+ "cSpell.words": [
43
+ "arkit",
44
+ "autogenerated",
45
+ "scrollable",
46
+ "serializable"
47
+ ],
48
+ "debug.javascript.unmapMissingSources": true,
49
+ "javascript.preferences.importModuleSpecifier": "relative",
50
+ "typescript.preferences.importModuleSpecifier": "relative",
51
+ "eslint.useFlatConfig": true,
52
+ "eslint.enable": true,
53
+ "eslint.validate": [
54
+ "javascript",
55
+ "javascriptreact",
56
+ "typescript",
57
+ "typescriptreact"
58
+ ],
59
+ "eslint.workingDirectories": [
60
+ "./"
61
+ ],
62
+ "typescript.validate.enable": true,
63
+ "editor.formatOnSave": false,
64
+ "editor.codeActionsOnSave": {
65
+ "source.fixAll.eslint": "always"
66
+ }
67
+ }
@@ -0,0 +1,112 @@
1
+ {
2
+ "version": "2.0.0",
3
+ "tasks": [
4
+ {
5
+ "type": "npm",
6
+ "script": "watch.build.dev",
7
+ "group": "build",
8
+ "label": "watch.build.dev & problem.watcher",
9
+ "isBackground": true,
10
+ "runOptions": {
11
+ "runOn": "folderOpen"
12
+ },
13
+ "promptOnClose": false,
14
+ "presentation": {
15
+ "focus": false,
16
+ "reveal": "never"
17
+ },
18
+ "problemMatcher": {
19
+ "base": "$tsc-watch",
20
+ "applyTo": "allDocuments"
21
+ }
22
+ },
23
+ {
24
+ "label": "test.file",
25
+ "command": "spruce",
26
+ "args": [
27
+ "test",
28
+ "--inspect",
29
+ "5200",
30
+ "--pattern",
31
+ "${fileBasenameNoExtension}",
32
+ "--watchMode",
33
+ "standard"
34
+ ],
35
+ "promptOnClose": false,
36
+ "group": {
37
+ "kind": "test",
38
+ "isDefault": true
39
+ },
40
+ "presentation": {
41
+ "reveal": "always",
42
+ "panel": "dedicated",
43
+ },
44
+ "problemMatcher": []
45
+ },
46
+ {
47
+ "label": "test.reporter",
48
+ "command": "spruce",
49
+ "args": [
50
+ "test",
51
+ "--shouldHoldAtStart",
52
+ "true",
53
+ "--watchMode",
54
+ "smart"
55
+ ],
56
+ "promptOnClose": false,
57
+ "group": "test",
58
+ "runOptions": {
59
+ "runOn": "folderOpen"
60
+ },
61
+ "presentation": {
62
+ "panel": "shared",
63
+ "focus": true,
64
+ "reveal": "always"
65
+ }
66
+ },
67
+ {
68
+ "label": "spruce",
69
+ "type": "shell",
70
+ "command": "spruce ${input:spruceCommand}",
71
+ "problemMatcher": [],
72
+ "presentation": {
73
+ "reveal": "always",
74
+ "focus": true,
75
+ "panel": "new",
76
+ "clear": false
77
+ }
78
+ },
79
+ {
80
+ "label": "shell",
81
+ "type": "shell",
82
+ "command": "${input:command} ${input:optionsCommand}",
83
+ "problemMatcher": [],
84
+ "presentation": {
85
+ "reveal": "always",
86
+ "focus": true,
87
+ "panel": "new",
88
+ "clear": false
89
+ }
90
+ }
91
+ ],
92
+ "inputs": [
93
+ {
94
+ "id": "spruceCommand",
95
+ "description": "spruce command",
96
+ "default": "create.test",
97
+ "type": "promptString"
98
+ },
99
+ {
100
+ "id": "command",
101
+ "description": "command",
102
+ "default": "yarn",
103
+ "type": "promptString"
104
+ },
105
+ {
106
+ "id": "optionsCommand",
107
+ "description": "optionsCommand",
108
+ "default": "add",
109
+ "type": "promptString"
110
+ }
111
+ ]
112
+ }
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 neurodevs
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 whom the Software is
10
+ furnished to do so, subject to the 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 ADDED
@@ -0,0 +1,2 @@
1
+ # meta-node
2
+ Meta-layer utilities for maintaining Node.js package ecosystems.
@@ -0,0 +1,11 @@
1
+ {
2
+ "scriptUpdater": {
3
+ "skipped": []
4
+ },
5
+ "skipped": [
6
+ "skill"
7
+ ],
8
+ "installed": [
9
+ "test"
10
+ ]
11
+ }
@@ -0,0 +1,28 @@
1
+ import AbstractSpruceTest from '@sprucelabs/test-utils';
2
+ export default class AutoclonerTest extends AbstractSpruceTest {
3
+ private static instance;
4
+ private static originalDir;
5
+ private static originalExecSync;
6
+ private static originalExistsSync;
7
+ protected static beforeEach(): Promise<void>;
8
+ protected static canCreateAutocloner(): Promise<void>;
9
+ protected static throwsIfDirPathDoesNotExist(): Promise<void>;
10
+ protected static changesCurrentDirectoryToDirPath(): Promise<void>;
11
+ protected static callsGitCloneForEachUrl(): Promise<void>;
12
+ protected static doesNotCallGitCloneIfUrlExists(): Promise<void>;
13
+ protected static throwsIfGitCloneFails(): Promise<void>;
14
+ protected static worksWithPeriodInRepoName(): Promise<void>;
15
+ private static run;
16
+ private static fakeExecSync;
17
+ private static resetFakes;
18
+ private static chdirToOriginalDir;
19
+ private static generateUrl;
20
+ private static normalize;
21
+ private static get gitCloneFailedMessage();
22
+ private static callsToExecSync;
23
+ private static readonly urls;
24
+ private static readonly validDirPath;
25
+ private static readonly invalidDirPath;
26
+ private static readonly gitCloneFailedError;
27
+ private static GitAutocloner;
28
+ }
@@ -0,0 +1,158 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
19
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
22
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
23
+ };
24
+ var __importStar = (this && this.__importStar) || (function () {
25
+ var ownKeys = function(o) {
26
+ ownKeys = Object.getOwnPropertyNames || function (o) {
27
+ var ar = [];
28
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
+ return ar;
30
+ };
31
+ return ownKeys(o);
32
+ };
33
+ return function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ })();
41
+ var __importDefault = (this && this.__importDefault) || function (mod) {
42
+ return (mod && mod.__esModule) ? mod : { "default": mod };
43
+ };
44
+ var _a;
45
+ Object.defineProperty(exports, "__esModule", { value: true });
46
+ const process_1 = require("process");
47
+ const test_utils_1 = __importStar(require("@sprucelabs/test-utils"));
48
+ const GitAutocloner_1 = __importDefault(require("../../modules/GitAutocloner"));
49
+ class AutoclonerTest extends test_utils_1.default {
50
+ static async beforeEach() {
51
+ await super.beforeEach();
52
+ this.resetFakes();
53
+ this.fakeExecSync();
54
+ this.chdirToOriginalDir();
55
+ this.instance = this.GitAutocloner();
56
+ }
57
+ static async canCreateAutocloner() {
58
+ test_utils_1.assert.isTruthy(this.instance, 'Should create a new instance!');
59
+ }
60
+ static async throwsIfDirPathDoesNotExist() {
61
+ const err = await test_utils_1.assert.doesThrowAsync(() => this.run({ dirPath: this.invalidDirPath }));
62
+ test_utils_1.assert.isEqual(err.message, `dirPath does not exist: ${this.invalidDirPath}!`, 'Did not receive the expected error!');
63
+ }
64
+ static async changesCurrentDirectoryToDirPath() {
65
+ await this.run();
66
+ const actual = process.cwd().split('/').pop();
67
+ test_utils_1.assert.isEqual(actual, this.validDirPath, 'Should change current directory to the dirPath!');
68
+ }
69
+ static async callsGitCloneForEachUrl() {
70
+ await this.run();
71
+ this.urls.forEach((url) => {
72
+ test_utils_1.assert.doesInclude(this.callsToExecSync, `git clone ${url}`);
73
+ });
74
+ }
75
+ static async doesNotCallGitCloneIfUrlExists() {
76
+ await this.run();
77
+ this.callsToExecSync = [];
78
+ this.chdirToOriginalDir();
79
+ GitAutocloner_1.default.existsSync = () => true;
80
+ await this.run();
81
+ test_utils_1.assert.isLength(this.callsToExecSync, 0);
82
+ }
83
+ static async throwsIfGitCloneFails() {
84
+ GitAutocloner_1.default.execSync = (_command) => {
85
+ throw new Error(this.gitCloneFailedError);
86
+ };
87
+ const err = await test_utils_1.assert.doesThrowAsync(() => this.run());
88
+ test_utils_1.assert.isEqual(this.normalize(err.message), this.normalize(this.gitCloneFailedMessage), 'Did not receive the expected error!');
89
+ }
90
+ static async worksWithPeriodInRepoName() {
91
+ const repoName = `/${(0, test_utils_1.generateId)()}.${(0, test_utils_1.generateId)()}.git`;
92
+ await this.run({ urls: [repoName] });
93
+ }
94
+ static run(options) {
95
+ return this.instance.run({
96
+ urls: this.urls,
97
+ dirPath: this.validDirPath,
98
+ ...options,
99
+ });
100
+ }
101
+ static fakeExecSync() {
102
+ // @ts-ignore
103
+ GitAutocloner_1.default.execSync = (command) => {
104
+ this.callsToExecSync.push(command);
105
+ };
106
+ }
107
+ static resetFakes() {
108
+ GitAutocloner_1.default.execSync = this.originalExecSync;
109
+ GitAutocloner_1.default.existsSync = this.originalExistsSync;
110
+ }
111
+ static chdirToOriginalDir() {
112
+ (0, process_1.chdir)(this.originalDir);
113
+ }
114
+ static generateUrl() {
115
+ return `https://github.com/${(0, test_utils_1.generateId)()}.git`;
116
+ }
117
+ static normalize(input) {
118
+ return input.replace(/\s+/g, ' ').trim();
119
+ }
120
+ static get gitCloneFailedMessage() {
121
+ return `Git clone failed for repo: ${this.urls[0]}! Error: \n\n${this.gitCloneFailedError}\n\n`;
122
+ }
123
+ static GitAutocloner() {
124
+ return GitAutocloner_1.default.Create();
125
+ }
126
+ }
127
+ _a = AutoclonerTest;
128
+ AutoclonerTest.originalDir = process.cwd();
129
+ AutoclonerTest.originalExecSync = GitAutocloner_1.default.execSync;
130
+ AutoclonerTest.originalExistsSync = GitAutocloner_1.default.existsSync;
131
+ AutoclonerTest.callsToExecSync = [];
132
+ AutoclonerTest.urls = [_a.generateUrl(), _a.generateUrl()];
133
+ AutoclonerTest.validDirPath = 'src';
134
+ AutoclonerTest.invalidDirPath = (0, test_utils_1.generateId)();
135
+ AutoclonerTest.gitCloneFailedError = 'Failed to clone repo!';
136
+ exports.default = AutoclonerTest;
137
+ __decorate([
138
+ (0, test_utils_1.test)()
139
+ ], AutoclonerTest, "canCreateAutocloner", null);
140
+ __decorate([
141
+ (0, test_utils_1.test)()
142
+ ], AutoclonerTest, "throwsIfDirPathDoesNotExist", null);
143
+ __decorate([
144
+ (0, test_utils_1.test)()
145
+ ], AutoclonerTest, "changesCurrentDirectoryToDirPath", null);
146
+ __decorate([
147
+ (0, test_utils_1.test)()
148
+ ], AutoclonerTest, "callsGitCloneForEachUrl", null);
149
+ __decorate([
150
+ (0, test_utils_1.test)()
151
+ ], AutoclonerTest, "doesNotCallGitCloneIfUrlExists", null);
152
+ __decorate([
153
+ (0, test_utils_1.test)()
154
+ ], AutoclonerTest, "throwsIfGitCloneFails", null);
155
+ __decorate([
156
+ (0, test_utils_1.test)()
157
+ ], AutoclonerTest, "worksWithPeriodInRepoName", null);
158
+ //# sourceMappingURL=GitAutocloner.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GitAutocloner.test.js","sourceRoot":"","sources":["../../../src/__tests__/modules/GitAutocloner.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAA+B;AAC/B,qEAI+B;AAC/B,gFAGoC;AAEpC,MAAqB,cAAe,SAAQ,oBAAkB;IAMhD,MAAM,CAAC,KAAK,CAAC,UAAU;QAC7B,MAAM,KAAK,CAAC,UAAU,EAAE,CAAA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AAR,CAAQ;AACpB,6BAAc,GAAG,IAAA,uBAAU,GAAE,AAAf,CAAe;AAC7B,kCAAmB,GAAG,uBAAuB,AAA1B,CAA0B;kBApIpD,cAAc;AAiBR;IADtB,IAAA,iBAAI,GAAE;+CAGN;AAGsB;IADtB,IAAA,iBAAI,GAAE;uDAWN;AAGsB;IADtB,IAAA,iBAAI,GAAE;4DAWN;AAGsB;IADtB,IAAA,iBAAI,GAAE;mDAON;AAGsB;IADtB,IAAA,iBAAI,GAAE;0DAYN;AAGsB;IADtB,IAAA,iBAAI,GAAE;iDAaN;AAGsB;IADtB,IAAA,iBAAI,GAAE;qDAIN"}
@@ -0,0 +1,24 @@
1
+ import AbstractSpruceTest from '@sprucelabs/test-utils';
2
+ export default class NpmAutopackageTest extends AbstractSpruceTest {
3
+ private static instance;
4
+ protected static beforeEach(): Promise<void>;
5
+ protected static createsNpmAutopackageInstance(): Promise<void>;
6
+ protected static firstCallsChdirToInstallDir(): Promise<void>;
7
+ protected static thenCallsSpruceCreateModule(): Promise<void>;
8
+ protected static thenCallsChdirToNewlyCreatedDir(): Promise<void>;
9
+ protected static thenSetsUpNewGitRepo(): Promise<void>;
10
+ protected static thenCallsSpruceSetupVscode(): Promise<void>;
11
+ protected static thenGitCommitsVscodeChanges(): Promise<void>;
12
+ private static fakeExecToPreventActual;
13
+ private static fakeChdirToPreventActual;
14
+ private static callsToExecSync;
15
+ private static callsToChdir;
16
+ private static readonly packageName;
17
+ private static readonly packageDescription;
18
+ private static readonly gitNamespace;
19
+ private static readonly npmNamespace;
20
+ private static readonly installDir;
21
+ private static readonly createModuleCmd;
22
+ private static readonly defaultOptions;
23
+ private static NpmAutopackage;
24
+ }
@@ -0,0 +1,136 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
19
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
22
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
23
+ };
24
+ var __importStar = (this && this.__importStar) || (function () {
25
+ var ownKeys = function(o) {
26
+ ownKeys = Object.getOwnPropertyNames || function (o) {
27
+ var ar = [];
28
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
+ return ar;
30
+ };
31
+ return ownKeys(o);
32
+ };
33
+ return function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ })();
41
+ var __importDefault = (this && this.__importDefault) || function (mod) {
42
+ return (mod && mod.__esModule) ? mod : { "default": mod };
43
+ };
44
+ var _a;
45
+ Object.defineProperty(exports, "__esModule", { value: true });
46
+ const test_utils_1 = __importStar(require("@sprucelabs/test-utils"));
47
+ const NpmAutopackage_1 = __importDefault(require("../../modules/NpmAutopackage"));
48
+ class NpmAutopackageTest extends test_utils_1.default {
49
+ static async beforeEach() {
50
+ await super.beforeEach();
51
+ this.fakeExecToPreventActual();
52
+ this.fakeChdirToPreventActual();
53
+ this.instance = await this.NpmAutopackage();
54
+ }
55
+ static async createsNpmAutopackageInstance() {
56
+ test_utils_1.assert.isTruthy(this.instance, 'Should create an instance!');
57
+ }
58
+ static async firstCallsChdirToInstallDir() {
59
+ test_utils_1.assert.isEqual(this.callsToChdir[0], this.installDir, 'Should have changed dir!');
60
+ }
61
+ static async thenCallsSpruceCreateModule() {
62
+ test_utils_1.assert.isEqual(this.callsToExecSync[0], this.createModuleCmd, 'Should have called "spruce create.module"!');
63
+ }
64
+ static async thenCallsChdirToNewlyCreatedDir() {
65
+ test_utils_1.assert.isEqual(this.callsToChdir[1], `${this.installDir}/${this.packageName}`, 'Should have changed dir!');
66
+ }
67
+ static async thenSetsUpNewGitRepo() {
68
+ test_utils_1.assert.isEqualDeep(this.callsToExecSync.slice(1, 5), [
69
+ 'git init',
70
+ 'git add .',
71
+ 'git commit -m "patch: create module"',
72
+ `git remote add origin "https://github.com/${this.gitNamespace}/${this.packageName}.git"`,
73
+ ], 'Should have called "git init"!');
74
+ }
75
+ static async thenCallsSpruceSetupVscode() {
76
+ test_utils_1.assert.isEqual(this.callsToExecSync[5], 'spruce setup.vscode --all true', 'Should have called "spruce setup.vscode"!');
77
+ }
78
+ static async thenGitCommitsVscodeChanges() {
79
+ test_utils_1.assert.isEqualDeep(this.callsToExecSync.slice(6, 8), ['git add .', 'git commit -m "patch: setup vscode"'], 'Should have committed vscode changes!');
80
+ }
81
+ static fakeExecToPreventActual() {
82
+ // @ts-ignore
83
+ NpmAutopackage_1.default.execSync = (cmd) => {
84
+ this.callsToExecSync.push(cmd);
85
+ };
86
+ this.callsToExecSync = [];
87
+ }
88
+ static fakeChdirToPreventActual() {
89
+ NpmAutopackage_1.default.chdir = (dir) => {
90
+ this.callsToChdir.push(dir);
91
+ };
92
+ this.callsToChdir = [];
93
+ }
94
+ static NpmAutopackage(options) {
95
+ return NpmAutopackage_1.default.Create({ ...this.defaultOptions, ...options });
96
+ }
97
+ }
98
+ _a = NpmAutopackageTest;
99
+ NpmAutopackageTest.callsToExecSync = [];
100
+ NpmAutopackageTest.callsToChdir = [];
101
+ NpmAutopackageTest.packageName = (0, test_utils_1.generateId)();
102
+ NpmAutopackageTest.packageDescription = (0, test_utils_1.generateId)();
103
+ NpmAutopackageTest.gitNamespace = (0, test_utils_1.generateId)();
104
+ NpmAutopackageTest.npmNamespace = (0, test_utils_1.generateId)();
105
+ NpmAutopackageTest.installDir = (0, test_utils_1.generateId)();
106
+ NpmAutopackageTest.createModuleCmd = `spruce create.module --name "${_a.packageName}" --destination "${_a.installDir}/${_a.packageName}" --description "${_a.packageDescription}"`;
107
+ NpmAutopackageTest.defaultOptions = {
108
+ name: _a.packageName,
109
+ description: _a.packageDescription,
110
+ gitNamespace: _a.gitNamespace,
111
+ npmNamespace: _a.npmNamespace,
112
+ installDir: _a.installDir,
113
+ };
114
+ exports.default = NpmAutopackageTest;
115
+ __decorate([
116
+ (0, test_utils_1.test)()
117
+ ], NpmAutopackageTest, "createsNpmAutopackageInstance", null);
118
+ __decorate([
119
+ (0, test_utils_1.test)()
120
+ ], NpmAutopackageTest, "firstCallsChdirToInstallDir", null);
121
+ __decorate([
122
+ (0, test_utils_1.test)()
123
+ ], NpmAutopackageTest, "thenCallsSpruceCreateModule", null);
124
+ __decorate([
125
+ (0, test_utils_1.test)()
126
+ ], NpmAutopackageTest, "thenCallsChdirToNewlyCreatedDir", null);
127
+ __decorate([
128
+ (0, test_utils_1.test)()
129
+ ], NpmAutopackageTest, "thenSetsUpNewGitRepo", null);
130
+ __decorate([
131
+ (0, test_utils_1.test)()
132
+ ], NpmAutopackageTest, "thenCallsSpruceSetupVscode", null);
133
+ __decorate([
134
+ (0, test_utils_1.test)()
135
+ ], NpmAutopackageTest, "thenGitCommitsVscodeChanges", null);
136
+ //# sourceMappingURL=NpmAutopackage.test.js.map
@@ -0,0 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B,+BAAY,GAAa,EAAE,AAAf,CAAe;AAElB,8BAAW,GAAG,IAAA,uBAAU,GAAE,AAAf,CAAe;AAC1B,qCAAkB,GAAG,IAAA,uBAAU,GAAE,AAAf,CAAe;AACjC,+BAAY,GAAG,IAAA,uBAAU,GAAE,AAAf,CAAe;AAC3B,+BAAY,GAAG,IAAA,uBAAU,GAAE,AAAf,CAAe;AAC3B,6BAAU,GAAG,IAAA,uBAAU,GAAE,AAAf,CAAe;AAEzB,kCAAe,GAAG,gCAAgC,EAAI,CAAC,WAAW,oBAAoB,EAAI,CAAC,UAAU,IAAI,EAAI,CAAC,WAAW,oBAAoB,EAAI,CAAC,kBAAkB,GAAG,AAAxJ,CAAwJ;AAEvK,iCAAc,GAAG;IACrC,IAAI,EAAE,EAAI,CAAC,WAAW;IACtB,WAAW,EAAE,EAAI,CAAC,kBAAkB;IACpC,YAAY,EAAE,EAAI,CAAC,YAAY;IAC/B,YAAY,EAAE,EAAI,CAAC,YAAY;IAC/B,UAAU,EAAE,EAAI,CAAC,UAAU;CAC9B,AANqC,CAMrC;kBA5GgB,kBAAkB;AAaZ;IADtB,IAAA,iBAAI,GAAE;6DAGN;AAGsB;IADtB,IAAA,iBAAI,GAAE;2DAON;AAGsB;IADtB,IAAA,iBAAI,GAAE;2DAON;AAGsB;IADtB,IAAA,iBAAI,GAAE;+DAON;AAGsB;IADtB,IAAA,iBAAI,GAAE;oDAYN;AAGsB;IADtB,IAAA,iBAAI,GAAE;0DAON;AAGsB;IADtB,IAAA,iBAAI,GAAE;2DAON"}
@@ -0,0 +1,6 @@
1
+ export { default as NpmAutopackage } from './modules/NpmAutopackage';
2
+ export * from './modules/NpmAutopackage';
3
+ export { default as GitAutocloner } from './modules/GitAutocloner';
4
+ export * from './modules/GitAutocloner';
5
+ export { default as FakeAutocloner } from './testDoubles/Autocloner/FakeAutocloner';
6
+ export * from './testDoubles/Autocloner/FakeAutocloner';