dew 0.0.52 → 0.7.30
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/bin/dew +211 -6
- package/package.json +12 -23
- package/.npmignore +0 -27
- package/.travis.yml +0 -3
- package/LICENSE +0 -21
- package/README.md +0 -19
- package/bin/detest +0 -10
- package/bin/undew +0 -10
- package/lib/detest.js +0 -23
- package/lib/dew.js +0 -35
- package/lib/helpFunctions.js +0 -43
- package/lib/makeFile.js +0 -16
- package/lib/makeTest.js +0 -16
- package/lib/undew.js +0 -22
package/bin/dew
CHANGED
|
@@ -1,10 +1,215 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
2
|
"use strict";
|
|
4
|
-
var path = require( 'path' );
|
|
5
|
-
var fs = require( 'fs' );
|
|
6
|
-
var lib = path.join( path.dirname( fs.realpathSync( __filename ) ), '../lib' );
|
|
7
3
|
|
|
8
|
-
|
|
4
|
+
// Thin dispatcher for @solcreek/dew.
|
|
5
|
+
//
|
|
6
|
+
// First run downloads the matching native binary from the GitHub Release
|
|
7
|
+
// for this package version, verifies SHA256 against checksums.txt, and
|
|
8
|
+
// caches in DEW_CACHE_DIR. Subsequent runs spawn the cached binary directly.
|
|
9
|
+
//
|
|
10
|
+
// We don't ship the binary inside the npm package — it lives in
|
|
11
|
+
// goreleaser-produced tarballs on GH Releases. This keeps the npm tarball
|
|
12
|
+
// tiny (no binary bytes touched by npm install), avoids per-platform
|
|
13
|
+
// publish setups, and lets brew/install.sh/direct download all consume
|
|
14
|
+
// the same exact bytes from one canonical source.
|
|
15
|
+
//
|
|
16
|
+
// Override: DEW_BINARY=/path/to/dew for local builds and testing.
|
|
17
|
+
// Override: DEW_CACHE_DIR=/path overrides the cache location.
|
|
18
|
+
// Set DEW_VERIFY_COSIGN=1 to hard-require cosign signature verification.
|
|
19
|
+
|
|
20
|
+
const fs = require("fs");
|
|
21
|
+
const path = require("path");
|
|
22
|
+
const os = require("os");
|
|
23
|
+
const https = require("https");
|
|
24
|
+
const crypto = require("crypto");
|
|
25
|
+
const zlib = require("zlib");
|
|
26
|
+
const { spawnSync } = require("child_process");
|
|
27
|
+
const { pipeline } = require("stream/promises");
|
|
28
|
+
const { createWriteStream, createReadStream } = require("fs");
|
|
29
|
+
|
|
30
|
+
const pkg = require("../package.json");
|
|
31
|
+
const VERSION = pkg.version;
|
|
32
|
+
const REPO = "solcreek/dew";
|
|
33
|
+
|
|
34
|
+
const SUPPORTED = {
|
|
35
|
+
"darwin-arm64": { goos: "darwin", goarch: "arm64", binName: "dew" },
|
|
36
|
+
"darwin-x64": { goos: "darwin", goarch: "amd64", binName: "dew" },
|
|
37
|
+
"linux-x64": { goos: "linux", goarch: "amd64", binName: "dew" },
|
|
38
|
+
"linux-arm64": { goos: "linux", goarch: "arm64", binName: "dew" },
|
|
39
|
+
"win32-x64": { goos: "windows", goarch: "amd64", binName: "dew.exe" },
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
function fatal(msg) {
|
|
43
|
+
process.stderr.write(`dew: ${msg}\n`);
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function cacheDir() {
|
|
48
|
+
if (process.env.DEW_CACHE_DIR) return process.env.DEW_CACHE_DIR;
|
|
49
|
+
const xdg = process.env.XDG_DATA_HOME;
|
|
50
|
+
const base = xdg || path.join(os.homedir(), ".local", "share");
|
|
51
|
+
return path.join(base, "dew", "bin", VERSION);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function get(url) {
|
|
55
|
+
return new Promise((resolve, reject) => {
|
|
56
|
+
https.get(url, (res) => {
|
|
57
|
+
if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
|
|
58
|
+
res.resume();
|
|
59
|
+
return resolve(get(res.headers.location));
|
|
60
|
+
}
|
|
61
|
+
if (res.statusCode !== 200) {
|
|
62
|
+
return reject(new Error(`HTTP ${res.statusCode} ${url}`));
|
|
63
|
+
}
|
|
64
|
+
resolve(res);
|
|
65
|
+
}).on("error", reject);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
async function downloadTo(url, destPath) {
|
|
70
|
+
const res = await get(url);
|
|
71
|
+
await pipeline(res, createWriteStream(destPath));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
async function fetchText(url) {
|
|
75
|
+
const res = await get(url);
|
|
76
|
+
let body = "";
|
|
77
|
+
for await (const chunk of res) body += chunk;
|
|
78
|
+
return body;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function sha256OfFile(p) {
|
|
82
|
+
const h = crypto.createHash("sha256");
|
|
83
|
+
return new Promise((resolve, reject) => {
|
|
84
|
+
const s = createReadStream(p);
|
|
85
|
+
s.on("data", (d) => h.update(d));
|
|
86
|
+
s.on("end", () => resolve(h.digest("hex")));
|
|
87
|
+
s.on("error", reject);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Extract a single named file from a tar.gz with no native deps.
|
|
92
|
+
// Tar layout: 512-byte header, payload padded to 512.
|
|
93
|
+
function extractTarGz(archivePath, outDir, binName) {
|
|
94
|
+
const buf = zlib.gunzipSync(fs.readFileSync(archivePath));
|
|
95
|
+
let off = 0;
|
|
96
|
+
while (off + 512 <= buf.length) {
|
|
97
|
+
const header = buf.subarray(off, off + 512);
|
|
98
|
+
const nameRaw = header.subarray(0, 100).toString("utf8").replace(/\0.*$/, "");
|
|
99
|
+
if (!nameRaw) { off += 512; continue; }
|
|
100
|
+
const sizeOctal = header.subarray(124, 136).toString("utf8").replace(/[\0 ]+$/, "");
|
|
101
|
+
const size = parseInt(sizeOctal, 8) || 0;
|
|
102
|
+
const typeflag = String.fromCharCode(header[156]) || "0";
|
|
103
|
+
const dataStart = off + 512;
|
|
104
|
+
const dataEnd = dataStart + size;
|
|
105
|
+
if ((typeflag === "0" || typeflag === "") && path.basename(nameRaw) === binName) {
|
|
106
|
+
const dest = path.join(outDir, binName);
|
|
107
|
+
fs.writeFileSync(dest, buf.subarray(dataStart, dataEnd));
|
|
108
|
+
fs.chmodSync(dest, 0o755);
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
off = dataEnd + (size % 512 === 0 ? 0 : 512 - (size % 512));
|
|
112
|
+
}
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
async function maybeVerifyCosign(dir, sumsBody) {
|
|
117
|
+
const verifyMode = process.env.DEW_VERIFY_COSIGN || "";
|
|
118
|
+
const cosignAvailable = spawnSync("cosign", ["version"], { stdio: "ignore" }).status === 0;
|
|
119
|
+
if (verifyMode !== "1" && !cosignAvailable) return;
|
|
120
|
+
|
|
121
|
+
const base = `https://github.com/${REPO}/releases/download/v${VERSION}`;
|
|
122
|
+
const sumsPath = path.join(dir, "checksums.txt");
|
|
123
|
+
const sigPath = path.join(dir, "checksums.txt.sig");
|
|
124
|
+
const pemPath = path.join(dir, "checksums.txt.pem");
|
|
125
|
+
fs.writeFileSync(sumsPath, sumsBody);
|
|
126
|
+
try {
|
|
127
|
+
await downloadTo(`${base}/checksums.txt.sig`, sigPath);
|
|
128
|
+
await downloadTo(`${base}/checksums.txt.pem`, pemPath);
|
|
129
|
+
} catch (e) {
|
|
130
|
+
if (verifyMode === "1") fatal(`cosign sig fetch failed: ${e.message}`);
|
|
131
|
+
process.stderr.write("dew: cosign verification skipped (signature absent)\n");
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
const r = spawnSync("cosign", [
|
|
135
|
+
"verify-blob",
|
|
136
|
+
"--certificate", pemPath,
|
|
137
|
+
"--signature", sigPath,
|
|
138
|
+
"--certificate-identity-regexp",
|
|
139
|
+
`^https://github.com/${REPO}/\\.github/workflows/release\\.yml@refs/tags/v[0-9]+\\.[0-9]+\\.[0-9]+`,
|
|
140
|
+
"--certificate-oidc-issuer", "https://token.actions.githubusercontent.com",
|
|
141
|
+
sumsPath,
|
|
142
|
+
], { stdio: verifyMode === "1" ? "inherit" : "pipe" });
|
|
143
|
+
if (r.status !== 0) {
|
|
144
|
+
if (verifyMode === "1") fatal("cosign verification failed");
|
|
145
|
+
process.stderr.write("dew: cosign verification failed (continuing — set DEW_VERIFY_COSIGN=1 to enforce)\n");
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
process.stderr.write("dew: cosign verified\n");
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
async function ensureBinary() {
|
|
152
|
+
const triple = `${process.platform}-${process.arch}`;
|
|
153
|
+
const spec = SUPPORTED[triple];
|
|
154
|
+
if (!spec) {
|
|
155
|
+
fatal(
|
|
156
|
+
`${process.platform}/${process.arch} is not a supported platform.\n` +
|
|
157
|
+
`Supported: ${Object.keys(SUPPORTED).join(", ")}.\n` +
|
|
158
|
+
`If you have built dew from source, set DEW_BINARY=/path/to/dew.`,
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const dir = cacheDir();
|
|
163
|
+
const binPath = path.join(dir, spec.binName);
|
|
164
|
+
if (fs.existsSync(binPath)) return binPath;
|
|
165
|
+
|
|
166
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
167
|
+
const tarName = `dew_${VERSION}_${spec.goos}_${spec.goarch}.tar.gz`;
|
|
168
|
+
const base = `https://github.com/${REPO}/releases/download/v${VERSION}`;
|
|
169
|
+
const tarUrl = `${base}/${tarName}`;
|
|
170
|
+
const sumUrl = `${base}/checksums.txt`;
|
|
171
|
+
const tarPath = path.join(dir, tarName);
|
|
172
|
+
|
|
173
|
+
process.stderr.write(`dew: downloading ${tarName}\n`);
|
|
174
|
+
try {
|
|
175
|
+
await downloadTo(tarUrl, tarPath);
|
|
176
|
+
} catch (e) {
|
|
177
|
+
fatal(`download failed: ${e.message}\n Set DEW_BINARY=/path/to/dew to bypass.`);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
process.stderr.write(`dew: verifying checksum\n`);
|
|
181
|
+
let sums;
|
|
182
|
+
try { sums = await fetchText(sumUrl); }
|
|
183
|
+
catch (e) { fatal(`could not fetch checksums.txt: ${e.message}`); }
|
|
184
|
+
const line = sums.split("\n").find((l) => l.endsWith(` ${tarName}`));
|
|
185
|
+
if (!line) fatal(`checksums.txt has no entry for ${tarName}`);
|
|
186
|
+
const expected = line.split(/\s+/)[0];
|
|
187
|
+
const actual = await sha256OfFile(tarPath);
|
|
188
|
+
if (actual !== expected) {
|
|
189
|
+
fs.unlinkSync(tarPath);
|
|
190
|
+
fatal(`checksum mismatch for ${tarName}\n expected ${expected}\n got ${actual}`);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
await maybeVerifyCosign(dir, sums);
|
|
194
|
+
|
|
195
|
+
process.stderr.write(`dew: extracting\n`);
|
|
196
|
+
if (!extractTarGz(tarPath, dir, spec.binName)) {
|
|
197
|
+
fatal(`tarball missing ${spec.binName}`);
|
|
198
|
+
}
|
|
199
|
+
fs.unlinkSync(tarPath);
|
|
200
|
+
return binPath;
|
|
201
|
+
}
|
|
9
202
|
|
|
10
|
-
|
|
203
|
+
(async () => {
|
|
204
|
+
const override = process.env.DEW_BINARY;
|
|
205
|
+
let bin;
|
|
206
|
+
if (override) {
|
|
207
|
+
if (!fs.existsSync(override)) fatal(`DEW_BINARY=${override} does not exist`);
|
|
208
|
+
bin = override;
|
|
209
|
+
} else {
|
|
210
|
+
bin = await ensureBinary();
|
|
211
|
+
}
|
|
212
|
+
const result = spawnSync(bin, process.argv.slice(2), { stdio: "inherit" });
|
|
213
|
+
if (result.error) fatal(result.error.message);
|
|
214
|
+
process.exit(result.status === null ? 1 : result.status);
|
|
215
|
+
})().catch((e) => fatal(e.message));
|
package/package.json
CHANGED
|
@@ -1,34 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dew",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.7.30",
|
|
4
|
+
"description": "Sandboxed Linux compute, agent-native and human-friendly.",
|
|
5
|
+
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
|
-
"url": "https://github.com/
|
|
9
|
-
},
|
|
10
|
-
"license": "MIT",
|
|
11
|
-
"bugs": {
|
|
12
|
-
"url": "https://github.com/wlabranche/dew/issues"
|
|
8
|
+
"url": "git+https://github.com/solcreek/dew.git"
|
|
13
9
|
},
|
|
14
|
-
"
|
|
15
|
-
"
|
|
10
|
+
"bin": {
|
|
11
|
+
"dew": "bin/dew"
|
|
16
12
|
},
|
|
17
|
-
"
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
"make",
|
|
21
|
-
"tests",
|
|
22
|
-
"magic"
|
|
13
|
+
"files": [
|
|
14
|
+
"bin/dew",
|
|
15
|
+
"README.md"
|
|
23
16
|
],
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"undew": "./bin/undew",
|
|
27
|
-
"detest": "./bin/detest"
|
|
17
|
+
"scripts": {
|
|
18
|
+
"test": "node --test test/*.test.mjs"
|
|
28
19
|
},
|
|
29
|
-
"preferGlobal": true,
|
|
30
|
-
"dependencies": {},
|
|
31
20
|
"engines": {
|
|
32
|
-
"node": "
|
|
21
|
+
"node": ">=18"
|
|
33
22
|
}
|
|
34
23
|
}
|
package/.npmignore
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
# Logs
|
|
2
|
-
logs
|
|
3
|
-
*.log
|
|
4
|
-
|
|
5
|
-
# Runtime data
|
|
6
|
-
pids
|
|
7
|
-
*.pid
|
|
8
|
-
*.seed
|
|
9
|
-
|
|
10
|
-
# Directory for instrumented libs generated by jscoverage/JSCover
|
|
11
|
-
lib-cov
|
|
12
|
-
|
|
13
|
-
# Coverage directory used by tools like istanbul
|
|
14
|
-
coverage
|
|
15
|
-
|
|
16
|
-
# gulp intermediate storage
|
|
17
|
-
.gulp
|
|
18
|
-
|
|
19
|
-
# Compiled binary addons (http://nodejs.org/api/addons.html)
|
|
20
|
-
build/Release
|
|
21
|
-
|
|
22
|
-
# Dependency directory
|
|
23
|
-
# Deployed apps should consider commenting this line out:
|
|
24
|
-
# see https://npmjs.org/doc/faq.html#Should-I-check-my-node_modules-folder-into-git
|
|
25
|
-
node_modules
|
|
26
|
-
|
|
27
|
-
test
|
package/.travis.yml
DELETED
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2014 Will LaBranche
|
|
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
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
dew [](https://nodei.co/npm/dew/) [](https://travis-ci.org/wlabranche/dew)
|
|
2
|
-
====
|
|
3
|
-
|
|
4
|
-
```
|
|
5
|
-
npm install dew -g
|
|
6
|
-
```
|
|
7
|
-
`dew` creates a file, tests for that file, and add it to other files dependencies (when specified, not yet impletemented).
|
|
8
|
-
|
|
9
|
-
This is super alpha, I hope to get it doing more soon.
|
|
10
|
-
|
|
11
|
-
As of now, this only works on javascript and coffeescript files, it defaults to javascript.
|
|
12
|
-
To use make and remove coffeescript files use the full path name.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
`dew <filename>` will generate a file and a test file for you, basically it's an optimized touch.
|
|
16
|
-
|
|
17
|
-
`undew <filename>` will remove the file and any tests associated with it.
|
|
18
|
-
|
|
19
|
-
`detest <filename>` removes test file for specified file, currently assumes '-test'.
|
package/bin/detest
DELETED
package/bin/undew
DELETED
package/lib/detest.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var fs = require( 'fs' );
|
|
4
|
-
var path = require( 'path' );
|
|
5
|
-
|
|
6
|
-
module.exports = function() {
|
|
7
|
-
var file, suffix, full;
|
|
8
|
-
|
|
9
|
-
if ( process.argv.length > 2 ) {
|
|
10
|
-
file = process.argv[2].split( '.' )[0];
|
|
11
|
-
suffix = process.argv[2].split( '.' )[1] || 'js';
|
|
12
|
-
full = file + '-file' + '.' + suffix;
|
|
13
|
-
if (fs.existsSync( file + '-test' + '.' + suffix ) ) {
|
|
14
|
-
fs.unlinkSync(file + '-test' + '.' + suffix);
|
|
15
|
-
console.log( 'the test shoudld be gone' );
|
|
16
|
-
} else {
|
|
17
|
-
console.log( 'there isn\'t a test for that...' );
|
|
18
|
-
}
|
|
19
|
-
} else {
|
|
20
|
-
// in the future this may want to ask about removing all tests from dir
|
|
21
|
-
console.log( 'you need to want to destroy something...' );
|
|
22
|
-
}
|
|
23
|
-
};
|
package/lib/dew.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var fs = require( 'fs' );
|
|
4
|
-
var makeFile = require( './makeFile.js' );
|
|
5
|
-
var makeTest = require( './makeTest.js' );
|
|
6
|
-
|
|
7
|
-
module.exports = function() {
|
|
8
|
-
var file, suffix, output, testFile;
|
|
9
|
-
if ( process.argv.length > 2 ){
|
|
10
|
-
file = process.argv[2].split( '.' )[0];
|
|
11
|
-
suffix = process.argv[2].split( '.' )[1] || 'js';
|
|
12
|
-
if ( suffix !== 'js' && suffix !== 'coffee' ){
|
|
13
|
-
console.log( 'this only works on javscript and coffeescript' );
|
|
14
|
-
} else {
|
|
15
|
-
if ( fs.existsSync( file + '.' + suffix ) ){
|
|
16
|
-
console.log( 'file already exists...' );
|
|
17
|
-
if ( fs.existsSync( file + '-test.' + suffix ) ){
|
|
18
|
-
console.log( 'so does the test, there is nothing for me to d...' );
|
|
19
|
-
} else {
|
|
20
|
-
testFile = makeTest( file, suffix );
|
|
21
|
-
fs.writeFileSync( file + '-test.' + suffix, testFile );
|
|
22
|
-
console.log( 'so I made you a test!' );
|
|
23
|
-
}
|
|
24
|
-
} else {
|
|
25
|
-
output = makeFile( file, suffix );
|
|
26
|
-
testFile = makeTest( file, suffix );
|
|
27
|
-
fs.writeFileSync( file + '.' + suffix, output );
|
|
28
|
-
fs.writeFileSync( file + '-test.' + suffix, testFile );
|
|
29
|
-
console.log( 'sorcery!' );
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}else{
|
|
33
|
-
console.log( 'specify a file to build' );
|
|
34
|
-
}
|
|
35
|
-
};
|
package/lib/helpFunctions.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var path = require( 'path' );
|
|
4
|
-
var fs = require( 'fs' );
|
|
5
|
-
var helpers = {};
|
|
6
|
-
|
|
7
|
-
helpers.coffeeTest = function( name ){
|
|
8
|
-
var file = name + ' = require "./' + name + '.coffee"\n' +
|
|
9
|
-
'expect = require chai.expect\n' +
|
|
10
|
-
'\n' +
|
|
11
|
-
'describe "' + name + '", ->\n' +
|
|
12
|
-
' it "should exist", ->\n' +
|
|
13
|
-
' expect( ' + name + ' ).to.exist';
|
|
14
|
-
|
|
15
|
-
return file;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
helpers.makeCoffee = function( name ){
|
|
19
|
-
var file = 'module.exports = {}';
|
|
20
|
-
|
|
21
|
-
return file;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
helpers.jsTest = function( name ){
|
|
25
|
-
var file = 'var ' + name + ' = require( "./' + name + '.js" );\n' +
|
|
26
|
-
'var expect = require("chai").expect;\n' +
|
|
27
|
-
'\n' +
|
|
28
|
-
'describe( "' + name + '", function() {\n' +
|
|
29
|
-
' it( "should exist", function() {\n' +
|
|
30
|
-
' return expect( ' + name + ' ).to.exist;\n' +
|
|
31
|
-
' } );' +
|
|
32
|
-
'} );';
|
|
33
|
-
|
|
34
|
-
return file;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
helpers.makeJS = function( name ){
|
|
38
|
-
var file = 'module.exports = {}';
|
|
39
|
-
|
|
40
|
-
return file;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
module.exports = helpers;
|
package/lib/makeFile.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var fs = require( 'fs' );
|
|
4
|
-
var path = require( 'path' );
|
|
5
|
-
var helpers = require( './helpFunctions.js' );
|
|
6
|
-
|
|
7
|
-
// make file
|
|
8
|
-
module.exports = function( name, suffix ) {
|
|
9
|
-
if ( suffix === 'js' ){
|
|
10
|
-
return helpers.makeJS( name );
|
|
11
|
-
}else if( suffix === 'coffee' ){
|
|
12
|
-
return helpers.makeCoffee( name );
|
|
13
|
-
}else{
|
|
14
|
-
console.log( 'not sure how you did it, but you broke everything. Great job...' );
|
|
15
|
-
}
|
|
16
|
-
};
|
package/lib/makeTest.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var fs = require( 'fs' );
|
|
4
|
-
var path = require( 'path' );
|
|
5
|
-
var helpers = require( './helpFunctions.js' );
|
|
6
|
-
|
|
7
|
-
// make test
|
|
8
|
-
module.exports = function( name, suffix ) {
|
|
9
|
-
if ( suffix === 'js' ){
|
|
10
|
-
return helpers.jsTest( name );
|
|
11
|
-
} else if ( suffix === 'coffee' ){
|
|
12
|
-
return helpers.coffeeTest( name );
|
|
13
|
-
} else {
|
|
14
|
-
console.log( 'something has gone horribly wrong' );
|
|
15
|
-
}
|
|
16
|
-
};
|
package/lib/undew.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var fs = require( 'fs' );
|
|
4
|
-
|
|
5
|
-
module.exports = function() {
|
|
6
|
-
var file, suffix;
|
|
7
|
-
if ( process.argv.length > 2 ){
|
|
8
|
-
file = process.argv[2].split( '.' )[0];
|
|
9
|
-
suffix = process.argv[2].split( '.' )[1] || 'js';
|
|
10
|
-
if ( fs.existsSync(file + '.' + suffix )){
|
|
11
|
-
fs.unlinkSync( file + '.' + suffix );
|
|
12
|
-
if ( fs.existsSync( file + '-test' + '.' + suffix ) ){
|
|
13
|
-
fs.unlinkSync( file + '-test' + '.' + suffix );
|
|
14
|
-
};
|
|
15
|
-
console.log( 'they should be gone forever' );
|
|
16
|
-
}else{
|
|
17
|
-
console.log( 'that doesn\'t exist... so... DONE!' );
|
|
18
|
-
}
|
|
19
|
-
}else{
|
|
20
|
-
console.log( 'input something for me to banish, please' );
|
|
21
|
-
}
|
|
22
|
-
};
|