mirror of
https://github.com/smogon/sprites.git
synced 2026-09-28 04:09:42 -05:00
deploy: add basic hash support so we can Just Ship It
This commit is contained in:
14
pnpm-lock.yaml
generated
14
pnpm-lock.yaml
generated
@@ -30,6 +30,7 @@ importers:
|
|||||||
tools/deploy:
|
tools/deploy:
|
||||||
specifiers:
|
specifiers:
|
||||||
'@types/tar-stream': ^2.2.2
|
'@types/tar-stream': ^2.2.2
|
||||||
|
base32-encode: ^2.0.0
|
||||||
commander: ^5.1.0
|
commander: ^5.1.0
|
||||||
debug: ^4.1.1
|
debug: ^4.1.1
|
||||||
expect: ^26.4.1
|
expect: ^26.4.1
|
||||||
@@ -37,6 +38,7 @@ importers:
|
|||||||
tar-stream: ^3.0.0
|
tar-stream: ^3.0.0
|
||||||
dependencies:
|
dependencies:
|
||||||
'@types/tar-stream': 2.2.2
|
'@types/tar-stream': 2.2.2
|
||||||
|
base32-encode: 2.0.0
|
||||||
commander: 5.1.0
|
commander: 5.1.0
|
||||||
debug: 4.1.1
|
debug: 4.1.1
|
||||||
tar-stream: 3.0.0
|
tar-stream: 3.0.0
|
||||||
@@ -321,6 +323,13 @@ packages:
|
|||||||
resolution: {integrity: sha1-ibTRmasr7kneFk6gK4nORi1xt2c=}
|
resolution: {integrity: sha1-ibTRmasr7kneFk6gK4nORi1xt2c=}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/base32-encode/2.0.0:
|
||||||
|
resolution: {integrity: sha512-mlmkfc2WqdDtMl/id4qm3A7RjW6jxcbAoMjdRmsPiwQP0ufD4oXItYMnPgVHe80lnAIy+1xwzhHE1s4FoIceSw==}
|
||||||
|
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
|
||||||
|
dependencies:
|
||||||
|
to-data-view: 2.0.0
|
||||||
|
dev: false
|
||||||
|
|
||||||
/base64-js/1.3.1:
|
/base64-js/1.3.1:
|
||||||
resolution: {integrity: sha512-mLQ4i2QO1ytvGWFWmcngKO//JXAQueZvwEKtjgQFM4jIK0kU+ytMfplL8j+n5mspOfjHwoAg+9yhb7BwAHm36g==}
|
resolution: {integrity: sha512-mLQ4i2QO1ytvGWFWmcngKO//JXAQueZvwEKtjgQFM4jIK0kU+ytMfplL8j+n5mspOfjHwoAg+9yhb7BwAHm36g==}
|
||||||
dev: false
|
dev: false
|
||||||
@@ -1991,6 +2000,11 @@ packages:
|
|||||||
xtend: 4.0.2
|
xtend: 4.0.2
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
|
/to-data-view/2.0.0:
|
||||||
|
resolution: {integrity: sha512-RGEM5KqlPHr+WVTPmGNAXNeFEmsBnlkxXaIfEpUYV0AST2Z5W1EGq9L/MENFrMMmL2WQr1wjkmZy/M92eKhjYA==}
|
||||||
|
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
|
||||||
|
dev: false
|
||||||
|
|
||||||
/to-regex-range/5.0.1:
|
/to-regex-range/5.0.1:
|
||||||
resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==}
|
resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==}
|
||||||
engines: {node: '>=8.0'}
|
engines: {node: '>=8.0'}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ function spritecopy(f, {dir, ext}) {
|
|||||||
if (sn.extra.has("a") || sn.extra.has("b") || sn.extra.has("s")) {
|
if (sn.extra.has("a") || sn.extra.has("b") || sn.extra.has("s")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sn.extension) {
|
if (sn.extension) {
|
||||||
// Skip this, we don't use Unknown/Substitute
|
// Skip this, we don't use Unknown/Substitute
|
||||||
return;
|
return;
|
||||||
@@ -34,7 +34,7 @@ function spritecopy(f, {dir, ext}) {
|
|||||||
if (sn.extra.has("g")) {
|
if (sn.extra.has("g")) {
|
||||||
name += "-gmax";
|
name += "-gmax";
|
||||||
}
|
}
|
||||||
|
|
||||||
copy(f, {dir, ext, name});
|
copy(f, {dir, ext, name});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,9 +82,11 @@ for (const f of list("build/item-minisprites-trimmed")) {
|
|||||||
itemspritecopy(f, {dir: "xyitems"});
|
itemspritecopy(f, {dir: "xyitems"});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let h = hash(...list("build/smogon/minisprites"));
|
||||||
for (const f of list("build/smogon/minisprites")) {
|
for (const f of list("build/smogon/minisprites")) {
|
||||||
newspritecopy(f, {dir: "minisprites"});
|
newspritecopy(f, {dir: "minisprites/" + h});
|
||||||
}
|
}
|
||||||
|
write("minisprites/hash.txt", h);
|
||||||
|
|
||||||
for (const f of list("build/item-minisprites-padded")) {
|
for (const f of list("build/item-minisprites-padded")) {
|
||||||
itemspritecopy(f, {dir: "forumsprites"});
|
itemspritecopy(f, {dir: "forumsprites"});
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/tar-stream": "^2.2.2",
|
"@types/tar-stream": "^2.2.2",
|
||||||
|
"base32-encode": "^2.0.0",
|
||||||
"commander": "^5.1.0",
|
"commander": "^5.1.0",
|
||||||
"debug": "^4.1.1",
|
"debug": "^4.1.1",
|
||||||
"tar-stream": "^3.0.0"
|
"tar-stream": "^3.0.0"
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ import vm from 'vm';
|
|||||||
import * as pathlib from './path.js';
|
import * as pathlib from './path.js';
|
||||||
import * as spritedata from '@smogon/sprite-data';
|
import * as spritedata from '@smogon/sprite-data';
|
||||||
import tar from 'tar-stream';
|
import tar from 'tar-stream';
|
||||||
|
import crypto from 'crypto';
|
||||||
|
import b32encode from 'base32-encode';
|
||||||
|
|
||||||
type Op = {
|
type Op = {
|
||||||
type : 'Write',
|
type : 'Write',
|
||||||
@@ -240,6 +241,18 @@ function makeEnv2(srcDir : string, queue: ActionQueue) {
|
|||||||
return fs.readFileSync(nodePath.join(srcDir, src), 'utf8');
|
return fs.readFileSync(nodePath.join(srcDir, src), 'utf8');
|
||||||
},
|
},
|
||||||
|
|
||||||
|
hash(...srcps : pathlib.PathLike[]) : string {
|
||||||
|
let hash = crypto.createHash("sha256");
|
||||||
|
let srcs = srcps.map(srcp => pathlib.format(pathlib.path(srcp))).sort();
|
||||||
|
for (let src of srcs) {
|
||||||
|
let data = fs.readFileSync(nodePath.join(srcDir, src));
|
||||||
|
hash.update(data);
|
||||||
|
}
|
||||||
|
let buffer = hash.digest()
|
||||||
|
// Similar to esbuild?
|
||||||
|
return b32encode(buffer, 'RFC4648').slice(0, 8);
|
||||||
|
},
|
||||||
|
|
||||||
write(dstp : pathlib.PathLike, data : string) {
|
write(dstp : pathlib.PathLike, data : string) {
|
||||||
const dst = pathlib.format(pathlib.path(dstp));
|
const dst = pathlib.format(pathlib.path(dstp));
|
||||||
queue.write(data, dst);
|
queue.write(data, dst);
|
||||||
|
|||||||
Reference in New Issue
Block a user