dep: Use smol-toml instead of toml (#164)

Fixed #162 #163

The former is listed on
https://github.com/toml-lang/toml/wiki#implementations and is toml 1.0
compliant.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
Jiahao XU 2023-08-19 20:23:03 +10:00 committed by GitHub
parent 578b235f6e
commit ab6b2769d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 1921 additions and 8154 deletions

5025
dist/restore/index.js vendored

File diff suppressed because it is too large Load Diff

5025
dist/save/index.js vendored

File diff suppressed because it is too large Load Diff

14
package-lock.json generated
View File

@ -15,7 +15,7 @@
"@actions/exec": "^1.1.1", "@actions/exec": "^1.1.1",
"@actions/glob": "^0.4.0", "@actions/glob": "^0.4.0",
"@actions/io": "^1.1.3", "@actions/io": "^1.1.3",
"toml": "^3.0.0" "smol-toml": "^1.1.1"
}, },
"devDependencies": { "devDependencies": {
"@vercel/ncc": "^0.36.1", "@vercel/ncc": "^0.36.1",
@ -511,10 +511,14 @@
"semver": "bin/semver.js" "semver": "bin/semver.js"
} }
}, },
"node_modules/toml": { "node_modules/smol-toml": {
"version": "3.0.0", "version": "1.1.1",
"resolved": "https://registry.npmjs.org/toml/-/toml-3.0.0.tgz", "resolved": "https://registry.npmjs.org/smol-toml/-/smol-toml-1.1.1.tgz",
"integrity": "sha512-y/mWCZinnvxjTKYhJ+pYxwD0mRLVvOtdS2Awbgxln6iEnt4rk0yBxeSBHkGJcPucRiG0e55mwWp+g/05rsrd6w==" "integrity": "sha512-qyYMygHyDKiy82iiKTH/zXr0DZmEpsou0AMZnkXdYhA/0LhPLoZ/xHaOBrbecLbAJ/Gd5KhMWWH8TXtgv1g+DQ==",
"engines": {
"node": ">= 18",
"pnpm": ">= 8"
}
}, },
"node_modules/tr46": { "node_modules/tr46": {
"version": "0.0.3", "version": "0.0.3",

View File

@ -28,7 +28,7 @@
"@actions/exec": "^1.1.1", "@actions/exec": "^1.1.1",
"@actions/glob": "^0.4.0", "@actions/glob": "^0.4.0",
"@actions/io": "^1.1.3", "@actions/io": "^1.1.3",
"toml": "^3.0.0" "smol-toml": "^1.1.1"
}, },
"devDependencies": { "devDependencies": {
"@vercel/ncc": "^0.36.1", "@vercel/ncc": "^0.36.1",

View File

@ -5,7 +5,7 @@ import fs from "fs";
import fs_promises from "fs/promises"; import fs_promises from "fs/promises";
import os from "os"; import os from "os";
import path from "path"; import path from "path";
import * as toml from "toml"; import * as toml from "smol-toml";
import { getCargoBins } from "./cleanup"; import { getCargoBins } from "./cleanup";
import { CacheProvider, getCmdOutput } from "./utils"; import { CacheProvider, getCmdOutput } from "./utils";
@ -147,12 +147,13 @@ export class CacheConfig {
for (const cargo_manifest of cargo_manifests) { for (const cargo_manifest of cargo_manifests) {
try { try {
const content = await fs_promises.readFile(cargo_manifest, { encoding: "utf8" }); const content = await fs_promises.readFile(cargo_manifest, { encoding: "utf8" });
const parsed = toml.parse(content); // Use any since TomlPrimitive is not exposed
const parsed = toml.parse(content) as { [key: string]: any };
if ("package" in parsed) { if ("package" in parsed) {
const pack = parsed.package; const pack = parsed.package;
if ("version" in pack) { if ("version" in pack) {
pack.version = "0.0.0"; pack["version"] = "0.0.0";
} }
} }
@ -205,7 +206,7 @@ export class CacheConfig {
// Package without `[[package]].source` and `[[package]].checksum` // Package without `[[package]].source` and `[[package]].checksum`
// are the one with `path = "..."` to crates within the workspace. // are the one with `path = "..."` to crates within the workspace.
const packages = parsed.package.filter((p: any) => "source" in p || "checksum" in p); const packages = (parsed.package as any[]).filter((p: any) => "source" in p || "checksum" in p);
hasher.update(JSON.stringify(packages)); hasher.update(JSON.stringify(packages));