Skip to content

Commit

Permalink
adding tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Jake Lauer authored and Jake Lauer committed Mar 24, 2024
1 parent ccca4cc commit 33490ee
Show file tree
Hide file tree
Showing 9 changed files with 558 additions and 103 deletions.
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.eslintrc.cjs
packages/publisher
packages/**/*
dist
node_modules
.husky
Expand Down
17 changes: 17 additions & 0 deletions .gptignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
.DS_STORE
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*
node_modules/
jspm_packages/
dist
.pnp.*
*.zip
*.tgz
.husky
.vscode
.git
153 changes: 77 additions & 76 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,77 +1,78 @@
{
"private": false,
"name": "theseus-js",
"version": "1.0.9",
"type": "module",
"description": "Functionality to create and modify data fluently and narratively",
"author": "Jake Lauer",
"license": "MIT",
"scripts": {
"prepublish": "pnpm build",
"prepare": "husky install",
"// ==== TESTING ==== //": "",
"lint": "git add . && pnpm lint-staged",
"lint-fix": "eslint ./ --fix --resolve-plugins-relative-to=./",
"test:debug": "mocha --exit --config ./.mocharc.cjs --debug-mode",
"test": "mocha --exit --config ./.mocharc.cjs",
"// ==== BUILD ==== //": "",
"build": "pnpm lint-fix && tsc --project ./tsconfig.json && resolve-tspaths",
"live": "tsc --watch --project ./tsconfig.json && resolve-tspaths"
},
"dependencies": {
"@ungap/structured-clone": "^1.2.0",
"deep-equal": "^2.2.3",
"deep-extend": "^0.6.0",
"deep-freeze-strict": "^1.1.1",
"promise.allsettled": "^1.0.7",
"uuid": "^9.0.1",
"winston": "^3.12.0"
},
"devDependencies": {
"@theseus/publisher": "workspace:latest",
"@types/chai": "^4.3.12",
"@types/chai-as-promised": "^7.1.8",
"@types/deep-equal": "^1.0.4",
"@types/deep-extend": "^0.6.2",
"@types/deep-freeze-strict": "^1.1.2",
"@types/mocha": "^10.0.6",
"@types/node": "^20.11.25",
"@types/promise.allsettled": "^1.0.6",
"@types/sinon": "^17.0.3",
"@types/sinon-chai": "^3.2.12",
"@types/ungap__structured-clone": "^1.2.0",
"@types/uuid": "^9.0.8",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "^6.21.0",
"chai": "^4.4.1",
"chai-as-promised": "^7.1.1",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.10.0",
"eslint-plugin-mocha": "^10.4.1",
"husky": "^8.0.3",
"lint-staged": "^14.0.1",
"mocha": "^10.3.0",
"mocha-suppress-logs": "^0.4.1",
"prettier": "^3.2.5",
"prettier-plugin-jsdoc": "^1.3.0",
"resolve-tspaths": "^0.8.18",
"sinon": "^17.0.1",
"sinon-chai": "^3.7.0",
"structured-clone": "link:@types/@ungap/structured-clone",
"tsx": "^4.7.1",
"typescript": "^5.4.2"
},
"lint-staged": {
"*.ts": [
"prettier --write",
"eslint --fix --resolve-plugins-relative-to=./"
]
},
"main": "dist/index.js",
"directories": {
"dist": "dist"
},
"engines": {
"node": ">=16.x"
}
}
"private": false,
"name": "theseus-js",
"version": "1.0.9",
"type": "module",
"description": "Functionality to create and modify data fluently and narratively",
"author": "Jake Lauer",
"license": "MIT",
"scripts": {
"prepublish": "pnpm build",
"prepare": "husky install",
"// ==== TESTING ==== //": "",
"lint": "git add . && pnpm lint-staged",
"lint-fix": "eslint ./ --fix --resolve-plugins-relative-to=./",
"test:debug": "mocha --exit --config ./.mocharc.cjs --debug-mode",
"test": "mocha --exit --config ./.mocharc.cjs",
"// ==== BUILD ==== //": "",
"build": "pnpm lint-fix && tsc --project ./tsconfig.json && resolve-tspaths",
"live": "tsc --watch --project ./tsconfig.json && resolve-tspaths"
},
"dependencies": {
"@ungap/structured-clone": "^1.2.0",
"deep-equal": "^2.2.3",
"deep-extend": "^0.6.0",
"deep-freeze-strict": "^1.1.1",
"promise.allsettled": "^1.0.7",
"uuid": "^9.0.1",
"winston": "^3.12.0"
},
"devDependencies": {
"@theseus/publisher": "workspace:latest",
"@theseus/gpt-zip": "workspace:latest",
"@types/chai": "^4.3.12",
"@types/chai-as-promised": "^7.1.8",
"@types/deep-equal": "^1.0.4",
"@types/deep-extend": "^0.6.2",
"@types/deep-freeze-strict": "^1.1.2",
"@types/mocha": "^10.0.6",
"@types/node": "^20.11.25",
"@types/promise.allsettled": "^1.0.6",
"@types/sinon": "^17.0.3",
"@types/sinon-chai": "^3.2.12",
"@types/ungap__structured-clone": "^1.2.0",
"@types/uuid": "^9.0.8",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "^6.21.0",
"chai": "^4.4.1",
"chai-as-promised": "^7.1.1",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.10.0",
"eslint-plugin-mocha": "^10.4.1",
"husky": "^8.0.3",
"lint-staged": "^14.0.1",
"mocha": "^10.3.0",
"mocha-suppress-logs": "^0.4.1",
"prettier": "^3.2.5",
"prettier-plugin-jsdoc": "^1.3.0",
"resolve-tspaths": "^0.8.18",
"sinon": "^17.0.1",
"sinon-chai": "^3.7.0",
"structured-clone": "link:@types/@ungap/structured-clone",
"tsx": "^4.7.1",
"typescript": "^5.4.2"
},
"lint-staged": {
"*.ts": [
"prettier --write",
"eslint --fix --resolve-plugins-relative-to=./"
]
},
"main": "dist/index.js",
"directories": {
"dist": "dist"
},
"engines": {
"node": ">=16.x"
}
}
47 changes: 47 additions & 0 deletions packages/gpt-zip/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
const fs = require("fs");
const path = require("path");
const archiver = require("archiver");
const ignore = require("ignore");
const klawSync = require("klaw-sync");

(async function () {
// Get the current working directory
const cwd = process.cwd();

// Create a writable stream to the zip file
const output = fs.createWriteStream(path.join(cwd, "output.zip"));
const archive = archiver("zip", {
zlib: { level: 9 }, // Highest compression level
});

output.on("close", function () {
console.log(archive.pointer() + " total bytes");
console.log("Archiver has been finalized and the output file descriptor has closed.");
});

archive.pipe(output);

const FILE_IGNORE_PATH = path.join(cwd, ".gptignore");
const gitignore = ignore();
if (fs.existsSync(FILE_IGNORE_PATH)) {
gitignore.add(fs.readFileSync(FILE_IGNORE_PATH).toString());
}

const files = klawSync(".", {
nodir: true,
filter: (item) => !item.path.includes("node_modules"), // Ignore node_modules directories
});

files
.filter((file) => !gitignore.ignores(path.relative(".", file.path)))
.forEach((file) => {
const relativePath = path.relative(".", file.path);
const stats = fs.statSync(file.path);
if (stats.isFile()) {
archive.file(file.path, { name: relativePath });
}
});

// Finalize
await archive.finalize();
})();
23 changes: 23 additions & 0 deletions packages/gpt-zip/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "@theseus/gpt-zip",
"private": true,
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node index.js"
},
"bin": {
"gpt-zip": "./index.js"
},
"dependencies": {
"archiver": "^7.0.1",
"arg": "^5.0.1",
"ignore": "^5.3.1",
"klaw-sync": "^6.0.0",
"prompts": "^2.4.2"
},
"keywords": [],
"author": "",
"license": "ISC"
}
Loading

0 comments on commit 33490ee

Please sign in to comment.