Skip to content
当前页面

NPM 包新版本发布

json
{
  "name": "script",
  "exports": "./script.js",
  "dss": {
    "schedule": "rate(1h)"
  },
  "dependencies": {
    "@digshare/script": "^0.4.16"
  }
}
js
import {script, load} from '@digshare/script';

export default script(async state => {
  const {version: latest} = await load(
    'https://registry.npmjs.org/typescript/latest',
    'json',
  );

  if (!state) {
    // 初始化 state 为当前版本。
    return {
      state: {latest},
    };
  }

  if (state.latest === latest) {
    // 当前版本没有更新,不发送消息。
    return;
  }

  return {
    message: `TypeScript 发布了新版本 ${latest}`,
    state: {latest},
  };
});