@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.
- package/.nvmrc +1 -0
- package/.vscode/launch.json +58 -0
- package/.vscode/settings.json +67 -0
- package/.vscode/tasks.json +112 -0
- package/LICENSE +21 -0
- package/README.md +2 -0
- package/build/.spruce/settings.json +11 -0
- package/build/__tests__/modules/GitAutocloner.test.d.ts +28 -0
- package/build/__tests__/modules/GitAutocloner.test.js +158 -0
- package/build/__tests__/modules/GitAutocloner.test.js.map +1 -0
- package/build/__tests__/modules/NpmAutopackage.test.d.ts +24 -0
- package/build/__tests__/modules/NpmAutopackage.test.js +136 -0
- package/build/__tests__/modules/NpmAutopackage.test.js.map +1 -0
- package/build/index.d.ts +6 -0
- package/build/index.js +32 -0
- package/build/index.js.map +1 -0
- package/build/modules/GitAutocloner.d.ts +38 -0
- package/build/modules/GitAutocloner.js +84 -0
- package/build/modules/GitAutocloner.js.map +1 -0
- package/build/modules/NpmAutopackage.d.ts +44 -0
- package/build/modules/NpmAutopackage.js +83 -0
- package/build/modules/NpmAutopackage.js.map +1 -0
- package/build/scripts/runAutopackage.d.ts +1 -0
- package/build/scripts/runAutopackage.js +26 -0
- package/build/scripts/runAutopackage.js.map +1 -0
- package/build/testDoubles/Autocloner/FakeAutocloner.d.ts +8 -0
- package/build/testDoubles/Autocloner/FakeAutocloner.js +18 -0
- package/build/testDoubles/Autocloner/FakeAutocloner.js.map +1 -0
- package/eslint.config.mjs +3 -0
- package/package.json +66 -0
- package/src/.spruce/settings.json +11 -0
- package/src/__tests__/modules/GitAutocloner.test.ts +149 -0
- package/src/__tests__/modules/NpmAutopackage.test.ts +124 -0
- package/src/index.ts +12 -0
- package/src/modules/GitAutocloner.ts +115 -0
- package/src/modules/NpmAutopackage.ts +124 -0
- package/src/scripts/runAutopackage.ts +25 -0
- package/src/testDoubles/Autocloner/FakeAutocloner.ts +19 -0
- package/tsconfig.json +39 -0
package/build/index.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Autopackage
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
15
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
16
|
+
};
|
|
17
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.FakeAutocloner = exports.GitAutocloner = exports.NpmAutopackage = void 0;
|
|
22
|
+
var NpmAutopackage_1 = require("./modules/NpmAutopackage");
|
|
23
|
+
Object.defineProperty(exports, "NpmAutopackage", { enumerable: true, get: function () { return __importDefault(NpmAutopackage_1).default; } });
|
|
24
|
+
__exportStar(require("./modules/NpmAutopackage"), exports);
|
|
25
|
+
// Autocloner
|
|
26
|
+
var GitAutocloner_1 = require("./modules/GitAutocloner");
|
|
27
|
+
Object.defineProperty(exports, "GitAutocloner", { enumerable: true, get: function () { return __importDefault(GitAutocloner_1).default; } });
|
|
28
|
+
__exportStar(require("./modules/GitAutocloner"), exports);
|
|
29
|
+
var FakeAutocloner_1 = require("./testDoubles/Autocloner/FakeAutocloner");
|
|
30
|
+
Object.defineProperty(exports, "FakeAutocloner", { enumerable: true, get: function () { return __importDefault(FakeAutocloner_1).default; } });
|
|
31
|
+
__exportStar(require("./testDoubles/Autocloner/FakeAutocloner"), exports);
|
|
32
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,cAAc;;;;;;;;;;;;;;;;;;;;AAEd,2DAAoE;AAA3D,iIAAA,OAAO,OAAkB;AAClC,2DAAwC;AAExC,aAAa;AAEb,yDAAkE;AAAzD,+HAAA,OAAO,OAAiB;AACjC,0DAAuC;AAEvC,0EAAmF;AAA1E,iIAAA,OAAO,OAAkB;AAClC,0EAAuD"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { execSync } from 'child_process';
|
|
2
|
+
import { existsSync } from 'fs';
|
|
3
|
+
export default class GitAutocloner implements Autocloner {
|
|
4
|
+
static Class?: AutoclonerConstructor;
|
|
5
|
+
static execSync: typeof execSync;
|
|
6
|
+
static existsSync: typeof existsSync;
|
|
7
|
+
private urls;
|
|
8
|
+
private dirPath;
|
|
9
|
+
private currentUrl;
|
|
10
|
+
private currentError;
|
|
11
|
+
private log;
|
|
12
|
+
protected constructor();
|
|
13
|
+
static Create(): Autocloner;
|
|
14
|
+
run(options: AutoclonerOptions): Promise<void>;
|
|
15
|
+
private throwIfDirPathDoesNotExist;
|
|
16
|
+
private get dirPathDoesNotExistMessage();
|
|
17
|
+
private changeDirectoryToDirPath;
|
|
18
|
+
private cloneReposFromUrls;
|
|
19
|
+
private cloneCurrentUrl;
|
|
20
|
+
private tryToCloneRepo;
|
|
21
|
+
private throwGitCloneFailed;
|
|
22
|
+
private get gitCloneFailedMessage();
|
|
23
|
+
private get dirPathExists();
|
|
24
|
+
private get currentRepoName();
|
|
25
|
+
private get currentRepoExists();
|
|
26
|
+
private get repoExistsMessage();
|
|
27
|
+
private get existsSync();
|
|
28
|
+
private get execSync();
|
|
29
|
+
private readonly regex;
|
|
30
|
+
}
|
|
31
|
+
export interface Autocloner {
|
|
32
|
+
run(options: AutoclonerOptions): Promise<void>;
|
|
33
|
+
}
|
|
34
|
+
export type AutoclonerConstructor = new () => Autocloner;
|
|
35
|
+
export interface AutoclonerOptions {
|
|
36
|
+
urls: string[];
|
|
37
|
+
dirPath: string;
|
|
38
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const child_process_1 = require("child_process");
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const process_1 = require("process");
|
|
6
|
+
class GitAutocloner {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.log = console;
|
|
9
|
+
this.regex = /\/([a-zA-Z0-9_.-]+)\.git/;
|
|
10
|
+
}
|
|
11
|
+
static Create() {
|
|
12
|
+
return new (this.Class ?? this)();
|
|
13
|
+
}
|
|
14
|
+
async run(options) {
|
|
15
|
+
const { urls, dirPath } = options;
|
|
16
|
+
this.urls = urls;
|
|
17
|
+
this.dirPath = dirPath;
|
|
18
|
+
this.throwIfDirPathDoesNotExist();
|
|
19
|
+
this.changeDirectoryToDirPath();
|
|
20
|
+
this.cloneReposFromUrls();
|
|
21
|
+
}
|
|
22
|
+
throwIfDirPathDoesNotExist() {
|
|
23
|
+
if (!this.dirPathExists) {
|
|
24
|
+
throw new Error(this.dirPathDoesNotExistMessage);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
get dirPathDoesNotExistMessage() {
|
|
28
|
+
return `dirPath does not exist: ${this.dirPath}!`;
|
|
29
|
+
}
|
|
30
|
+
changeDirectoryToDirPath() {
|
|
31
|
+
(0, process_1.chdir)(this.dirPath);
|
|
32
|
+
}
|
|
33
|
+
cloneReposFromUrls() {
|
|
34
|
+
this.urls.forEach((url) => {
|
|
35
|
+
this.currentUrl = url;
|
|
36
|
+
this.cloneCurrentUrl();
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
cloneCurrentUrl() {
|
|
40
|
+
if (!this.currentRepoExists) {
|
|
41
|
+
this.tryToCloneRepo();
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
this.log.info(this.repoExistsMessage);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
tryToCloneRepo() {
|
|
48
|
+
try {
|
|
49
|
+
this.execSync(`git clone ${this.currentUrl}`);
|
|
50
|
+
}
|
|
51
|
+
catch (err) {
|
|
52
|
+
this.currentError = err;
|
|
53
|
+
this.throwGitCloneFailed();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
throwGitCloneFailed() {
|
|
57
|
+
throw new Error(this.gitCloneFailedMessage);
|
|
58
|
+
}
|
|
59
|
+
get gitCloneFailedMessage() {
|
|
60
|
+
return `Git clone failed for repo: ${this.currentUrl}!\n\n${this.currentError}\n\n`;
|
|
61
|
+
}
|
|
62
|
+
get dirPathExists() {
|
|
63
|
+
return this.existsSync(this.dirPath);
|
|
64
|
+
}
|
|
65
|
+
get currentRepoName() {
|
|
66
|
+
return this.currentUrl.match(this.regex)[1];
|
|
67
|
+
}
|
|
68
|
+
get currentRepoExists() {
|
|
69
|
+
return this.existsSync(this.currentRepoName);
|
|
70
|
+
}
|
|
71
|
+
get repoExistsMessage() {
|
|
72
|
+
return `Repo already exists, skipping: ${this.currentRepoName}!`;
|
|
73
|
+
}
|
|
74
|
+
get existsSync() {
|
|
75
|
+
return GitAutocloner.existsSync;
|
|
76
|
+
}
|
|
77
|
+
get execSync() {
|
|
78
|
+
return GitAutocloner.execSync;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
GitAutocloner.execSync = child_process_1.execSync;
|
|
82
|
+
GitAutocloner.existsSync = fs_1.existsSync;
|
|
83
|
+
exports.default = GitAutocloner;
|
|
84
|
+
//# sourceMappingURL=GitAutocloner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,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0,0 +1,44 @@
|
|
|
1
|
+
import { execSync } from 'child_process';
|
|
2
|
+
export default class NpmAutopackage implements Autopackage {
|
|
3
|
+
static Class?: AutopackageConstructor;
|
|
4
|
+
static chdir: (directory: string) => void;
|
|
5
|
+
static execSync: typeof execSync;
|
|
6
|
+
private packageName;
|
|
7
|
+
private packageDescription;
|
|
8
|
+
private gitNamespace;
|
|
9
|
+
private installDir;
|
|
10
|
+
protected constructor(options: AutopackageOptions);
|
|
11
|
+
static Create(options: AutopackageOptions): Promise<Autopackage>;
|
|
12
|
+
createPackage(): Promise<void>;
|
|
13
|
+
private execCreateModule;
|
|
14
|
+
private execGitSetup;
|
|
15
|
+
private gitInit;
|
|
16
|
+
private gitAdd;
|
|
17
|
+
private gitCommitCreateModule;
|
|
18
|
+
private gitRemoteAddOrigin;
|
|
19
|
+
private execSetupVscode;
|
|
20
|
+
private gitCommitSetupVscode;
|
|
21
|
+
private chdirToInstallDir;
|
|
22
|
+
private chdirToNewPackageDir;
|
|
23
|
+
private get packageDir();
|
|
24
|
+
private get chdir();
|
|
25
|
+
private get exec();
|
|
26
|
+
private get createModuleCmd();
|
|
27
|
+
private readonly initCmd;
|
|
28
|
+
private readonly addCmd;
|
|
29
|
+
private readonly commitCreateCmd;
|
|
30
|
+
private get addRemoteCmd();
|
|
31
|
+
private readonly setupVscodeCmd;
|
|
32
|
+
private readonly commitVscodeCmd;
|
|
33
|
+
}
|
|
34
|
+
export interface Autopackage {
|
|
35
|
+
createPackage(): Promise<void>;
|
|
36
|
+
}
|
|
37
|
+
export interface AutopackageOptions {
|
|
38
|
+
name: string;
|
|
39
|
+
description: string;
|
|
40
|
+
gitNamespace: string;
|
|
41
|
+
npmNamespace: string;
|
|
42
|
+
installDir: string;
|
|
43
|
+
}
|
|
44
|
+
export type AutopackageConstructor = new () => Autopackage;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const child_process_1 = require("child_process");
|
|
4
|
+
class NpmAutopackage {
|
|
5
|
+
constructor(options) {
|
|
6
|
+
this.initCmd = 'git init';
|
|
7
|
+
this.addCmd = 'git add .';
|
|
8
|
+
this.commitCreateCmd = 'git commit -m "patch: create module"';
|
|
9
|
+
this.setupVscodeCmd = 'spruce setup.vscode --all true';
|
|
10
|
+
this.commitVscodeCmd = 'git commit -m "patch: setup vscode"';
|
|
11
|
+
const { name, description, gitNamespace, installDir } = options;
|
|
12
|
+
this.packageName = name;
|
|
13
|
+
this.packageDescription = description;
|
|
14
|
+
this.gitNamespace = gitNamespace;
|
|
15
|
+
this.installDir = installDir;
|
|
16
|
+
}
|
|
17
|
+
static async Create(options) {
|
|
18
|
+
const instance = new (this.Class ?? this)(options);
|
|
19
|
+
await instance.createPackage();
|
|
20
|
+
return instance;
|
|
21
|
+
}
|
|
22
|
+
async createPackage() {
|
|
23
|
+
this.execCreateModule();
|
|
24
|
+
this.execGitSetup();
|
|
25
|
+
this.execSetupVscode();
|
|
26
|
+
}
|
|
27
|
+
execCreateModule() {
|
|
28
|
+
this.chdirToInstallDir();
|
|
29
|
+
this.exec(this.createModuleCmd);
|
|
30
|
+
}
|
|
31
|
+
execGitSetup() {
|
|
32
|
+
this.chdirToNewPackageDir();
|
|
33
|
+
this.gitInit();
|
|
34
|
+
this.gitAdd();
|
|
35
|
+
this.gitCommitCreateModule();
|
|
36
|
+
this.gitRemoteAddOrigin();
|
|
37
|
+
}
|
|
38
|
+
gitInit() {
|
|
39
|
+
this.exec(this.initCmd);
|
|
40
|
+
}
|
|
41
|
+
gitAdd() {
|
|
42
|
+
this.exec(this.addCmd);
|
|
43
|
+
}
|
|
44
|
+
gitCommitCreateModule() {
|
|
45
|
+
this.exec(this.commitCreateCmd);
|
|
46
|
+
}
|
|
47
|
+
gitRemoteAddOrigin() {
|
|
48
|
+
this.exec(this.addRemoteCmd);
|
|
49
|
+
}
|
|
50
|
+
execSetupVscode() {
|
|
51
|
+
this.exec(this.setupVscodeCmd);
|
|
52
|
+
this.gitAdd();
|
|
53
|
+
this.gitCommitSetupVscode();
|
|
54
|
+
}
|
|
55
|
+
gitCommitSetupVscode() {
|
|
56
|
+
this.exec(this.commitVscodeCmd);
|
|
57
|
+
}
|
|
58
|
+
chdirToInstallDir() {
|
|
59
|
+
this.chdir(this.installDir);
|
|
60
|
+
}
|
|
61
|
+
chdirToNewPackageDir() {
|
|
62
|
+
this.chdir(this.packageDir);
|
|
63
|
+
}
|
|
64
|
+
get packageDir() {
|
|
65
|
+
return `${this.installDir}/${this.packageName}`;
|
|
66
|
+
}
|
|
67
|
+
get chdir() {
|
|
68
|
+
return NpmAutopackage.chdir;
|
|
69
|
+
}
|
|
70
|
+
get exec() {
|
|
71
|
+
return NpmAutopackage.execSync;
|
|
72
|
+
}
|
|
73
|
+
get createModuleCmd() {
|
|
74
|
+
return `spruce create.module --name "${this.packageName}" --destination "${this.installDir}/${this.packageName}" --description "${this.packageDescription}"`;
|
|
75
|
+
}
|
|
76
|
+
get addRemoteCmd() {
|
|
77
|
+
return `git remote add origin "https://github.com/${this.gitNamespace}/${this.packageName}.git"`;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
NpmAutopackage.chdir = process.chdir;
|
|
81
|
+
NpmAutopackage.execSync = child_process_1.execSync;
|
|
82
|
+
exports.default = NpmAutopackage;
|
|
83
|
+
//# sourceMappingURL=NpmAutopackage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NpmAutopackage.js","sourceRoot":"","sources":["../../src/modules/NpmAutopackage.ts"],"names":[],"mappings":";;AAAA,iDAAwC;AAExC,MAAqB,cAAc;IAU/B,YAAsB,OAA2B;QAuFhC,YAAO,GAAG,UAAU,CAAA;QACpB,WAAM,GAAG,WAAW,CAAA;QACpB,oBAAe,GAAG,sCAAsC,CAAA;QAMxD,mBAAc,GAAG,gCAAgC,CAAA;QACjD,oBAAe,GAAG,qCAAqC,CAAA;QA/FpE,MAAM,EA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od) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const child_process_1 = require("child_process");
|
|
7
|
+
const NpmAutopackage_1 = __importDefault(require("../modules/NpmAutopackage"));
|
|
8
|
+
async function run() {
|
|
9
|
+
console.log('Running...');
|
|
10
|
+
await NpmAutopackage_1.default.Create({
|
|
11
|
+
name: 'node-xyz',
|
|
12
|
+
description: 'XYZ, yo',
|
|
13
|
+
gitNamespace: 'neurodevs',
|
|
14
|
+
npmNamespace: 'neurodevs',
|
|
15
|
+
installDir: '/Users/ericthecurious/dev',
|
|
16
|
+
});
|
|
17
|
+
console.log('Opening in VSCode...');
|
|
18
|
+
(0, child_process_1.execSync)('code .');
|
|
19
|
+
console.log('Done!');
|
|
20
|
+
process.exit(0);
|
|
21
|
+
}
|
|
22
|
+
run().catch((err) => {
|
|
23
|
+
console.error(err);
|
|
24
|
+
process.exit(1);
|
|
25
|
+
});
|
|
26
|
+
//# sourceMappingURL=runAutopackage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runAutopackage.js","sourceRoot":"","sources":["../../src/scripts/runAutopackage.ts"],"names":[],"mappings":";;;;;AAAA,iDAAwC;AACxC,+EAAsD;AAEtD,KAAK,UAAU,GAAG;IACd,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;IAEzB,MAAM,wBAAc,CAAC,MAAM,CAAC;QACxB,IAAI,EAAE,UAAU;QAChB,WAAW,EAAE,SAAS;QACtB,YAAY,EAAE,WAAW;QACzB,YAAY,EAAE,WAAW;QACzB,UAAU,EAAE,2BAA2B;KAC1C,CAAC,CAAA;IAEF,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAA;IACnC,IAAA,wBAAQ,EAAC,QAAQ,CAAC,CAAA;IAClB,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;IAEpB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACnB,CAAC;AAED,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IAChB,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAClB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACnB,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Autocloner, AutoclonerOptions } from '../../modules/GitAutocloner';
|
|
2
|
+
export default class FakeGitAutocloner implements Autocloner {
|
|
3
|
+
static numCallsToConstructor: number;
|
|
4
|
+
static callsToRun: AutoclonerOptions[];
|
|
5
|
+
constructor();
|
|
6
|
+
run(options: AutoclonerOptions): Promise<void>;
|
|
7
|
+
static resetTestDouble(): void;
|
|
8
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class FakeGitAutocloner {
|
|
4
|
+
constructor() {
|
|
5
|
+
FakeGitAutocloner.numCallsToConstructor++;
|
|
6
|
+
}
|
|
7
|
+
async run(options) {
|
|
8
|
+
FakeGitAutocloner.callsToRun.push(options);
|
|
9
|
+
}
|
|
10
|
+
static resetTestDouble() {
|
|
11
|
+
FakeGitAutocloner.numCallsToConstructor = 0;
|
|
12
|
+
FakeGitAutocloner.callsToRun = [];
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
FakeGitAutocloner.numCallsToConstructor = 0;
|
|
16
|
+
FakeGitAutocloner.callsToRun = [];
|
|
17
|
+
exports.default = FakeGitAutocloner;
|
|
18
|
+
//# sourceMappingURL=FakeAutocloner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FakeAutocloner.js","sourceRoot":"","sources":["../../../src/testDoubles/Autocloner/FakeAutocloner.ts"],"names":[],"mappings":";;AAEA,MAAqB,iBAAiB;IAIlC;QACI,iBAAiB,CAAC,qBAAqB,EAAE,CAAA;IAC7C,CAAC;IAEM,KAAK,CAAC,GAAG,CAAC,OAA0B;QACvC,iBAAiB,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IAC9C,CAAC;IAEM,MAAM,CAAC,eAAe;QACzB,iBAAiB,CAAC,qBAAqB,GAAG,CAAC,CAAA;QAC3C,iBAAiB,CAAC,UAAU,GAAG,EAAE,CAAA;IACrC,CAAC;;AAda,uCAAqB,GAAG,CAAC,CAAA;AACzB,4BAAU,GAAwB,EAAE,CAAA;kBAFjC,iBAAiB"}
|
package/package.json
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@neurodevs/meta-node",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Meta-layer utilities for maintaining Node.js package ecosystems.",
|
|
5
|
+
"repository": "https://github.com/neurodevs/meta-node.git",
|
|
6
|
+
"main": "build/index.js",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build.ci": "yarn run build.tsc && yarn run build.resolve-paths && yarn run lint",
|
|
9
|
+
"build.dev": "yarn run build.tsc --sourceMap ; yarn run resolve-paths.lint",
|
|
10
|
+
"build.copy-files": "mkdir -p build && rsync -avzq --exclude='*.ts' ./src/ ./build/",
|
|
11
|
+
"build.resolve-paths": "resolve-path-aliases --target build --patterns '**/*.js,**/*.d.ts'",
|
|
12
|
+
"build.tsc": "yarn run build.copy-files && tsc",
|
|
13
|
+
"clean": "yarn run clean.build",
|
|
14
|
+
"clean.all": "yarn run clean.dependencies && yarn run clean.build",
|
|
15
|
+
"clean.build": "rm -rf build/",
|
|
16
|
+
"clean.dependencies": "rm -rf node_modules/ package-lock.json yarn.lock",
|
|
17
|
+
"fix.lint": "eslint --fix --cache '**/*.ts'",
|
|
18
|
+
"lint": "eslint --cache '**/*.ts'",
|
|
19
|
+
"lint.tsc": "tsc -p . --noEmit",
|
|
20
|
+
"post.watch.build": "yarn run build.copy-files && yarn run build.resolve-paths",
|
|
21
|
+
"rebuild": "yarn run clean.all && yarn install && yarn run build.dev",
|
|
22
|
+
"update.dependencies": "yarn run clean.dependencies && yarn",
|
|
23
|
+
"resolve-paths.lint": "yarn run build.resolve-paths ; yarn run lint",
|
|
24
|
+
"test": "jest",
|
|
25
|
+
"watch.build.dev": "tsc-watch --sourceMap --onCompilationComplete 'yarn run post.watch.build'",
|
|
26
|
+
"watch.rebuild": "yarn run clean.all && yarn install && yarn run watch.build.dev",
|
|
27
|
+
"watch.tsc": "tsc -w"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@sprucelabs/jest-json-reporter": "^9.0.61",
|
|
31
|
+
"@sprucelabs/resolve-path-aliases": "^3.0.28",
|
|
32
|
+
"@sprucelabs/test": "^10.0.24",
|
|
33
|
+
"@sprucelabs/test-utils": "^6.0.94",
|
|
34
|
+
"@types/node": "^24.6.2",
|
|
35
|
+
"chokidar-cli": "^3.0.0",
|
|
36
|
+
"eslint": "^9.37.0",
|
|
37
|
+
"eslint-config-spruce": "^11.2.26",
|
|
38
|
+
"jest": "^30.2.0",
|
|
39
|
+
"jest-circus": "^30.2.0",
|
|
40
|
+
"prettier": "^3.6.2",
|
|
41
|
+
"ts-node": "^10.9.2",
|
|
42
|
+
"tsc-watch": "^7.2.0",
|
|
43
|
+
"typescript": "^5.9.3"
|
|
44
|
+
},
|
|
45
|
+
"jest": {
|
|
46
|
+
"testRunner": "jest-circus/runner",
|
|
47
|
+
"testEnvironment": "node",
|
|
48
|
+
"testTimeout": 120000,
|
|
49
|
+
"maxWorkers": 4,
|
|
50
|
+
"testPathIgnorePatterns": [
|
|
51
|
+
"<rootDir>/tmp/",
|
|
52
|
+
"<rootDir>/src/",
|
|
53
|
+
"<rootDir>/node_modules/",
|
|
54
|
+
"<rootDir>/build/__tests__/testDirsAndFiles/"
|
|
55
|
+
],
|
|
56
|
+
"testMatch": [
|
|
57
|
+
"**/__tests__/**/*.test.js?(x)"
|
|
58
|
+
],
|
|
59
|
+
"moduleNameMapper": {
|
|
60
|
+
"^#spruce/(.*)$": "<rootDir>/build/.spruce/$1"
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
"skill": {
|
|
64
|
+
"namespace": "meta-node"
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { chdir } from 'process'
|
|
2
|
+
import AbstractSpruceTest, {
|
|
3
|
+
test,
|
|
4
|
+
assert,
|
|
5
|
+
generateId,
|
|
6
|
+
} from '@sprucelabs/test-utils'
|
|
7
|
+
import GitAutocloner, {
|
|
8
|
+
Autocloner,
|
|
9
|
+
AutoclonerOptions,
|
|
10
|
+
} from '../../modules/GitAutocloner'
|
|
11
|
+
|
|
12
|
+
export default class AutoclonerTest extends AbstractSpruceTest {
|
|
13
|
+
private static instance: Autocloner
|
|
14
|
+
private static originalDir = process.cwd()
|
|
15
|
+
private static originalExecSync = GitAutocloner.execSync
|
|
16
|
+
private static originalExistsSync = GitAutocloner.existsSync
|
|
17
|
+
|
|
18
|
+
protected static async beforeEach() {
|
|
19
|
+
await super.beforeEach()
|
|
20
|
+
|
|
21
|
+
this.resetFakes()
|
|
22
|
+
this.fakeExecSync()
|
|
23
|
+
this.chdirToOriginalDir()
|
|
24
|
+
|
|
25
|
+
this.instance = this.GitAutocloner()
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
@test()
|
|
29
|
+
protected static async canCreateAutocloner() {
|
|
30
|
+
assert.isTruthy(this.instance, 'Should create a new instance!')
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@test()
|
|
34
|
+
protected static async throwsIfDirPathDoesNotExist() {
|
|
35
|
+
const err = await assert.doesThrowAsync(() =>
|
|
36
|
+
this.run({ dirPath: this.invalidDirPath })
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
assert.isEqual(
|
|
40
|
+
err.message,
|
|
41
|
+
`dirPath does not exist: ${this.invalidDirPath}!`,
|
|
42
|
+
'Did not receive the expected error!'
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@test()
|
|
47
|
+
protected static async changesCurrentDirectoryToDirPath() {
|
|
48
|
+
await this.run()
|
|
49
|
+
|
|
50
|
+
const actual = process.cwd().split('/').pop()
|
|
51
|
+
|
|
52
|
+
assert.isEqual(
|
|
53
|
+
actual,
|
|
54
|
+
this.validDirPath,
|
|
55
|
+
'Should change current directory to the dirPath!'
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
@test()
|
|
60
|
+
protected static async callsGitCloneForEachUrl() {
|
|
61
|
+
await this.run()
|
|
62
|
+
|
|
63
|
+
this.urls.forEach((url) => {
|
|
64
|
+
assert.doesInclude(this.callsToExecSync, `git clone ${url}`)
|
|
65
|
+
})
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
@test()
|
|
69
|
+
protected static async doesNotCallGitCloneIfUrlExists() {
|
|
70
|
+
await this.run()
|
|
71
|
+
|
|
72
|
+
this.callsToExecSync = []
|
|
73
|
+
this.chdirToOriginalDir()
|
|
74
|
+
|
|
75
|
+
GitAutocloner.existsSync = () => true
|
|
76
|
+
|
|
77
|
+
await this.run()
|
|
78
|
+
|
|
79
|
+
assert.isLength(this.callsToExecSync, 0)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
@test()
|
|
83
|
+
protected static async throwsIfGitCloneFails() {
|
|
84
|
+
GitAutocloner.execSync = (_command: string) => {
|
|
85
|
+
throw new Error(this.gitCloneFailedError)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const err = await assert.doesThrowAsync(() => this.run())
|
|
89
|
+
|
|
90
|
+
assert.isEqual(
|
|
91
|
+
this.normalize(err.message),
|
|
92
|
+
this.normalize(this.gitCloneFailedMessage),
|
|
93
|
+
'Did not receive the expected error!'
|
|
94
|
+
)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
@test()
|
|
98
|
+
protected static async worksWithPeriodInRepoName() {
|
|
99
|
+
const repoName = `/${generateId()}.${generateId()}.git`
|
|
100
|
+
await this.run({ urls: [repoName] })
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
private static run(options?: Partial<AutoclonerOptions>) {
|
|
104
|
+
return this.instance.run({
|
|
105
|
+
urls: this.urls,
|
|
106
|
+
dirPath: this.validDirPath,
|
|
107
|
+
...options,
|
|
108
|
+
})
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
private static fakeExecSync() {
|
|
112
|
+
// @ts-ignore
|
|
113
|
+
GitAutocloner.execSync = (command: string) => {
|
|
114
|
+
this.callsToExecSync.push(command)
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
private static resetFakes() {
|
|
119
|
+
GitAutocloner.execSync = this.originalExecSync
|
|
120
|
+
GitAutocloner.existsSync = this.originalExistsSync
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
private static chdirToOriginalDir() {
|
|
124
|
+
chdir(this.originalDir)
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
private static generateUrl() {
|
|
128
|
+
return `https://github.com/${generateId()}.git`
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
private static normalize(input: string) {
|
|
132
|
+
return input.replace(/\s+/g, ' ').trim()
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
private static get gitCloneFailedMessage() {
|
|
136
|
+
return `Git clone failed for repo: ${this.urls[0]}! Error: \n\n${this.gitCloneFailedError}\n\n`
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
private static callsToExecSync: string[] = []
|
|
140
|
+
|
|
141
|
+
private static readonly urls = [this.generateUrl(), this.generateUrl()]
|
|
142
|
+
private static readonly validDirPath = 'src'
|
|
143
|
+
private static readonly invalidDirPath = generateId()
|
|
144
|
+
private static readonly gitCloneFailedError = 'Failed to clone repo!'
|
|
145
|
+
|
|
146
|
+
private static GitAutocloner() {
|
|
147
|
+
return GitAutocloner.Create()
|
|
148
|
+
}
|
|
149
|
+
}
|