@sanity/plugin-kit 2.1.9 → 2.1.10
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/README.md
CHANGED
|
@@ -57,9 +57,10 @@ npx @sanity/plugin-kit init sanity-plugin-testing-it-out
|
|
|
57
57
|
cd sanity-plugin-testing-it-out
|
|
58
58
|
npm run link-watch
|
|
59
59
|
|
|
60
|
-
# In another shell, link the plugin to your Sanity studio
|
|
60
|
+
# In another shell, link the plugin to your Sanity studio using the command indicated by link-watch
|
|
61
61
|
cd /path/to/my-studio
|
|
62
|
-
yalc add
|
|
62
|
+
npx yalc add sanity-plugin-testing-it-out && npx yalc link sanity-plugin-testing-it-out && npm install
|
|
63
|
+
|
|
63
64
|
```
|
|
64
65
|
|
|
65
66
|
Now, configure the plugin in sanity.config.ts (or .js) in Sanity Studio:
|
package/lib/package.json
CHANGED
|
@@ -38,10 +38,11 @@ const path_1 = __importDefault(require("path"));
|
|
|
38
38
|
const log_1 = __importDefault(require("../util/log"));
|
|
39
39
|
const package_1 = require("../npm/package");
|
|
40
40
|
const outdent_1 = __importDefault(require("outdent"));
|
|
41
|
+
const files_1 = require("../util/files");
|
|
41
42
|
function linkWatch({ basePath }) {
|
|
42
43
|
var _a;
|
|
43
44
|
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
-
const packageJson = JSON.parse(fs_1.default.readFileSync(path_1.default.join(
|
|
45
|
+
const packageJson = JSON.parse(fs_1.default.readFileSync(path_1.default.join(basePath, 'package.json'), 'utf8'));
|
|
45
46
|
const watch = Object.assign({ folder: 'lib', command: 'npm run watch', extensions: 'ts,js,png,svg,gif,jpeg,css' }, (_a = packageJson.sanityPlugin) === null || _a === void 0 ? void 0 : _a.linkWatch);
|
|
46
47
|
(0, nodemon_1.default)({
|
|
47
48
|
watch: [watch.folder],
|
|
@@ -49,7 +50,13 @@ function linkWatch({ basePath }) {
|
|
|
49
50
|
exec: 'yalc push --changed',
|
|
50
51
|
//delay: 1000
|
|
51
52
|
});
|
|
53
|
+
// ensure the folder exits so it can be watched
|
|
54
|
+
const folder = path_1.default.join(basePath, watch.folder);
|
|
55
|
+
if (!(yield (0, files_1.fileExists)(folder))) {
|
|
56
|
+
yield (0, files_1.mkdir)(folder);
|
|
57
|
+
}
|
|
52
58
|
const pkg = yield (0, package_1.getPackage)({ basePath, validate: false });
|
|
59
|
+
(0, concurrently_1.default)([watch.command]);
|
|
53
60
|
nodemon_1.default
|
|
54
61
|
.on('start', function () {
|
|
55
62
|
log_1.default.info((0, outdent_1.default) `
|
|
@@ -66,7 +73,6 @@ function linkWatch({ basePath }) {
|
|
|
66
73
|
log_1.default.info('Found changes in files:', chalk_1.default.magentaBright(files));
|
|
67
74
|
log_1.default.info('Pushing new yalc package...');
|
|
68
75
|
});
|
|
69
|
-
(0, concurrently_1.default)([watch.command]);
|
|
70
76
|
});
|
|
71
77
|
}
|
|
72
78
|
exports.linkWatch = linkWatch;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link-watch.js","sourceRoot":"","sources":["../../../src/actions/link-watch.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;EAYE;;;;;;;;;;;;;;;AAEF;;;EAGE;AAEF,sDAA6B;AAC7B,gEAAuC;AACvC,kDAAyB;AACzB,4CAAmB;AACnB,gDAAuB;AACvB,sDAA6B;AAC7B,4CAAyC;AACzC,sDAA6B;
|
|
1
|
+
{"version":3,"file":"link-watch.js","sourceRoot":"","sources":["../../../src/actions/link-watch.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;EAYE;;;;;;;;;;;;;;;AAEF;;;EAGE;AAEF,sDAA6B;AAC7B,gEAAuC;AACvC,kDAAyB;AACzB,4CAAmB;AACnB,gDAAuB;AACvB,sDAA6B;AAC7B,4CAAyC;AACzC,sDAA6B;AAC7B,yCAA+C;AAY/C,SAAsB,SAAS,CAAC,EAAC,QAAQ,EAAqB;;;QAC5D,MAAM,WAAW,GAAgB,IAAI,CA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C,SAAS,EAAE,UAAU,KAAU;YACjC,aAAG,CAAC,IAAI,CAAC,yBAAyB,EAAE,eAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAA;YAC/D,aAAG,CAAC,IAAI,CAAC,6BAA6B,CAAC,CAAA;QACzC,CAAC,CAAC,CAAA;;CACL;AA/CD,8BA+CC"}
|
package/package.json
CHANGED
|
@@ -25,6 +25,7 @@ import path from 'path'
|
|
|
25
25
|
import log from '../util/log'
|
|
26
26
|
import {getPackage} from '../npm/package'
|
|
27
27
|
import outdent from 'outdent'
|
|
28
|
+
import {fileExists, mkdir} from '../util/files'
|
|
28
29
|
|
|
29
30
|
interface YalcWatchConfig {
|
|
30
31
|
folder?: string
|
|
@@ -38,7 +39,7 @@ interface PackageJson {
|
|
|
38
39
|
|
|
39
40
|
export async function linkWatch({basePath}: {basePath: string}) {
|
|
40
41
|
const packageJson: PackageJson = JSON.parse(
|
|
41
|
-
fs.readFileSync(path.join(
|
|
42
|
+
fs.readFileSync(path.join(basePath, 'package.json'), 'utf8')
|
|
42
43
|
)
|
|
43
44
|
|
|
44
45
|
const watch: Required<YalcWatchConfig> = {
|
|
@@ -55,8 +56,16 @@ export async function linkWatch({basePath}: {basePath: string}) {
|
|
|
55
56
|
//delay: 1000
|
|
56
57
|
})
|
|
57
58
|
|
|
59
|
+
// ensure the folder exits so it can be watched
|
|
60
|
+
const folder = path.join(basePath, watch.folder)
|
|
61
|
+
if (!(await fileExists(folder))) {
|
|
62
|
+
await mkdir(folder)
|
|
63
|
+
}
|
|
64
|
+
|
|
58
65
|
const pkg = await getPackage({basePath, validate: false})
|
|
59
66
|
|
|
67
|
+
concurrently([watch.command])
|
|
68
|
+
|
|
60
69
|
nodemon
|
|
61
70
|
.on('start', function () {
|
|
62
71
|
log.info(
|
|
@@ -75,6 +84,4 @@ export async function linkWatch({basePath}: {basePath: string}) {
|
|
|
75
84
|
log.info('Found changes in files:', chalk.magentaBright(files))
|
|
76
85
|
log.info('Pushing new yalc package...')
|
|
77
86
|
})
|
|
78
|
-
|
|
79
|
-
concurrently([watch.command])
|
|
80
87
|
}
|