@smartcat/sanity-functions 1.2.0 → 1.2.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/bin/cli.js +16 -7
- package/package.json +2 -2
package/bin/cli.js
CHANGED
|
@@ -6,14 +6,13 @@ import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from
|
|
|
6
6
|
|
|
7
7
|
// src/cli/init.ts
|
|
8
8
|
import path from "node:path";
|
|
9
|
-
var PKG = "@smartcat/sanity-functions";
|
|
10
9
|
function init(deps) {
|
|
11
10
|
const { packageRoot: packageRoot2, targetDir, force, fs, log } = deps;
|
|
12
11
|
if (fs.existsSync(targetDir) && fs.readdirSync(targetDir).length > 0 && !force) {
|
|
13
12
|
log(`Target ${targetDir} is not empty. Re-run with --force to overwrite.`);
|
|
14
13
|
return { code: 1, files: [] };
|
|
15
14
|
}
|
|
16
|
-
const
|
|
15
|
+
const funcPkg = JSON.parse(fs.readFileSync(path.join(packageRoot2, "package.json"), "utf8"));
|
|
17
16
|
const names = fs.readdirSync(path.join(packageRoot2, "functions")).filter((n) => fs.existsSync(path.join(packageRoot2, "functions", n, "index.ts")));
|
|
18
17
|
const files = [];
|
|
19
18
|
const write = (rel, content) => {
|
|
@@ -22,16 +21,26 @@ function init(deps) {
|
|
|
22
21
|
fs.writeFileSync(abs, content);
|
|
23
22
|
files.push(rel);
|
|
24
23
|
};
|
|
25
|
-
write(
|
|
26
|
-
|
|
24
|
+
const copy = (rel) => write(rel, fs.readFileSync(path.join(packageRoot2, rel), "utf8"));
|
|
25
|
+
copy("sanity.blueprint.ts");
|
|
27
26
|
for (const name of names) {
|
|
28
|
-
|
|
29
|
-
`);
|
|
27
|
+
copy(`functions/${name}/index.ts`);
|
|
30
28
|
}
|
|
29
|
+
const d = funcPkg.dependencies;
|
|
31
30
|
write(
|
|
32
31
|
"package.json",
|
|
33
32
|
`${JSON.stringify(
|
|
34
|
-
{
|
|
33
|
+
{
|
|
34
|
+
name: "smartcat-functions-deploy",
|
|
35
|
+
private: true,
|
|
36
|
+
type: "module",
|
|
37
|
+
dependencies: {
|
|
38
|
+
"@smartcat/sanity-plugin": `^${funcPkg.version}`,
|
|
39
|
+
"@sanity/blueprints": d["@sanity/blueprints"],
|
|
40
|
+
"@sanity/functions": d["@sanity/functions"],
|
|
41
|
+
"@sanity/client": d["@sanity/client"]
|
|
42
|
+
}
|
|
43
|
+
},
|
|
35
44
|
null,
|
|
36
45
|
2
|
|
37
46
|
)}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smartcat/sanity-functions",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"./package.json": "./package.json"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@smartcat/sanity-plugin": "1.2.
|
|
24
|
+
"@smartcat/sanity-plugin": "1.2.1",
|
|
25
25
|
"@sanity/blueprints": "^0.20.1",
|
|
26
26
|
"@sanity/functions": "^1.3.1",
|
|
27
27
|
"@sanity/client": "^7.22.1"
|