Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@digshare/script

Package Overview
Dependencies
Maintainers
3
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@digshare/script - npm Package Compare versions

Comparing version 0.4.0-1 to 0.4.0

bld/cli/@core/legacy.d.ts

4

bld/cli/@core/config.d.ts

@@ -12,3 +12,3 @@ export interface GlobalConfigRaw {

readonly globalConfigPath: string;
readonly localConfigPath: string;
readonly localConfigPath: string | undefined;
private globalRaw;

@@ -21,4 +21,4 @@ private localRaw;

};
constructor(globalConfigPath: string, localConfigPath: string);
constructor(globalConfigPath: string, localConfigPath: string | undefined);
setAccessToken(accessToken: string): void;
}

@@ -51,3 +51,6 @@ "use strict";

try {
this.localRaw = JSON.parse(FS.readFileSync(localConfigPath, 'utf8'));
this.localRaw =
localConfigPath === undefined
? {}
: JSON.parse(FS.readFileSync(localConfigPath, 'utf8'));
}

@@ -70,3 +73,5 @@ catch (error) {

this.localRaw.accessToken = accessToken;
FS.writeFileSync(this.localConfigPath, `${JSON.stringify(this.localRaw, undefined, 2)}\n`);
if (this.localConfigPath !== undefined) {
FS.writeFileSync(this.localConfigPath, `${JSON.stringify(this.localRaw, undefined, 2)}\n`);
}
}

@@ -73,0 +78,0 @@ }

@@ -8,1 +8,2 @@ export * from './pack';

export * from './invoke';
export * from './legacy';

@@ -11,2 +11,3 @@ "use strict";

tslib_1.__exportStar(require("./invoke"), exports);
tslib_1.__exportStar(require("./legacy"), exports);
//# sourceMappingURL=index.js.map

@@ -5,3 +5,3 @@ "use strict";

const tslib_1 = require("tslib");
const FS = tslib_1.__importStar(require("fs"));
const FS = tslib_1.__importStar(require("fs/promises"));
const Path = tslib_1.__importStar(require("path"));

@@ -16,3 +16,3 @@ const plugin_commonjs_1 = tslib_1.__importDefault(require("@rollup/plugin-commonjs"));

const VIRTUAL_ENTRY_NAME = './__entry.js';
const LOCAL_MAIN_FILE_PATH = Path.join(__dirname, '../../../res/local-main.mjs');
const LOCAL_MAIN_FILE_PATH = Path.join(__dirname, '../../../res/local-main.js');
function ROLLUP(entryCode, minify) {

@@ -53,6 +53,7 @@ return (0, rollup_1.rollup)({

const scriptModuleSpecifier = getScriptModuleSpecifier(projectDir);
const mainFileContent = await FS.readFile(LOCAL_MAIN_FILE_PATH, 'utf8');
const build = await ROLLUP(`\
import script from ${JSON.stringify(scriptModuleSpecifier)};
${FS.readFileSync(LOCAL_MAIN_FILE_PATH, 'utf8')}`, false);
${mainFileContent}`, false);
const outScript = Path.join(outDir, 'script.mjs');

@@ -59,0 +60,0 @@ await build.write({

import { API, Config } from './@core';
export declare class Entrances {
readonly configDir: string;
readonly projectDir: string;
constructor(configDir: string, projectDir: string);
private projectDir;
constructor(configDir: string, projectDir: string | undefined);
get workingDir(): string;
get config(): Config;
get api(): API;
}

@@ -24,4 +24,10 @@ "use strict";

/* eslint-disable @mufan/explicit-return-type */
get workingDir() {
var _a;
return (_a = this.projectDir) !== null && _a !== void 0 ? _a : process.cwd();
}
get config() {
return new _core_1.Config(Path.join(this.configDir, 'config.json'), Path.join(this.projectDir, '.dssrc'));
return new _core_1.Config(Path.join(this.configDir, 'config.json'), this.projectDir === undefined
? undefined
: Path.join(this.projectDir, '.dssrc'));
}

@@ -32,4 +38,8 @@ get api() {

}
exports.Entrances = Entrances;
tslib_1.__decorate([
entrance_decorator_1.entrance
], Entrances.prototype, "workingDir", null);
tslib_1.__decorate([
entrance_decorator_1.entrance
], Entrances.prototype, "config", null);

@@ -39,3 +49,2 @@ tslib_1.__decorate([

], Entrances.prototype, "api", null);
exports.Entrances = Entrances;
//# sourceMappingURL=@entrances.js.map

@@ -6,9 +6,9 @@ import { Command } from '../@command';

static flags: {
minify: import("@oclif/core/lib/interfaces/parser").BooleanFlag<boolean>;
debug: import("@oclif/core/lib/interfaces/parser").BooleanFlag<boolean>;
run: import("@oclif/core/lib/interfaces/parser").BooleanFlag<boolean>;
'dry-run': import("@oclif/core/lib/interfaces/parser").BooleanFlag<boolean>;
'reset-state': import("@oclif/core/lib/interfaces/parser").BooleanFlag<boolean>;
force: import("@oclif/core/lib/interfaces/parser").BooleanFlag<boolean>;
minify: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
debug: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
run: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
'dry-run': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
'reset-state': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
force: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
};
}

@@ -14,4 +14,5 @@ "use strict";

async run() {
const { entrances, entrances: { api, projectDir }, } = this;
const { entrances, entrances: { api, workingDir }, } = this;
const { flags: { minify, debug, run, 'dry-run': dryRun, 'reset-state': resetState, force, }, } = await this.parse(Deploy);
await (0, _core_1.ensureAccessToken)(entrances);
if (!force) {

@@ -43,7 +44,6 @@ if (!debug) {

}
const { dss = {} } = require(Path.join(projectDir, 'package.json'));
const { dss = {} } = require(Path.join(workingDir, 'package.json'));
const { schedule } = _core_1.ScriptOptions.exact().satisfies(dss);
await (0, _core_1.ensureAccessToken)(entrances);
this.log('正在打包…');
const code = await (0, _core_1.pack)(projectDir, { minify });
const code = await (0, _core_1.pack)(workingDir, { minify });
this.log('正在部署…');

@@ -50,0 +50,0 @@ await api.call('/v2/script/deploy', {

@@ -6,5 +6,5 @@ import { Command } from '../@command';

static flags: {
'reset-state': import("@oclif/core/lib/interfaces/parser").BooleanFlag<boolean>;
out: import("@oclif/core/lib/interfaces/parser").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
'reset-state': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
out: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
};
}

@@ -12,5 +12,5 @@ "use strict";

async run() {
const { entrances: { projectDir }, } = this;
const { entrances: { workingDir }, } = this;
const { flags: { out, 'reset-state': resetState }, } = await this.parse(LocalRun);
const outScript = await (0, _core_1.packLocal)(projectDir, Path.join(projectDir, out));
const outScript = await (0, _core_1.packLocal)(workingDir, Path.join(workingDir, out));
ChildProcess.spawn(process.argv[0], [outScript, JSON.stringify({ resetState })], { stdio: 'inherit' }).on('exit', code => process.exit(code !== null && code !== void 0 ? code : 0));

@@ -17,0 +17,0 @@ await new Promise(() => { });

@@ -6,5 +6,5 @@ import { Command } from '../@command';

static flags: {
debug: import("@oclif/core/lib/interfaces/parser").BooleanFlag<boolean>;
last: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
debug: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
last: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
};
}

@@ -13,4 +13,4 @@ "use strict";

const { flags: { debug, last }, } = await this.parse(Logs);
await (0, _core_1.ensureAccessToken)(entrances);
const startTime = last ? new Date(Date.now() - (0, ms_1.default)(last)) : undefined;
await (0, _core_1.ensureAccessToken)(entrances);
for await (const event of (0, _core_1.pollLogs)(entrances, { debug, startTime })) {

@@ -17,0 +17,0 @@ (0, _core_1.printLogEvent)(event);

@@ -6,5 +6,5 @@ import { Command } from '../@command';

static flags: {
out: import("@oclif/core/lib/interfaces/parser").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
minify: import("@oclif/core/lib/interfaces/parser").BooleanFlag<boolean>;
out: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
minify: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
};
}

@@ -11,9 +11,9 @@ "use strict";

async run() {
const { entrances: { projectDir }, } = this;
const { entrances: { workingDir }, } = this;
const { flags: { out, minify }, } = await this.parse(Pack);
this.log('正在打包…');
const path = Path.join(projectDir, out);
await (0, _core_1.pack)(projectDir, { out: path, minify });
const path = Path.join(workingDir, out);
await (0, _core_1.pack)(workingDir, { out: path, minify });
this.log('打包成功!');
this.log('文件路径', Path.relative(projectDir, path));
this.log('文件路径', Path.relative(workingDir, path));
this.exit();

@@ -20,0 +20,0 @@ }

@@ -6,6 +6,6 @@ import { Command } from '../@command';

static flags: {
debug: import("@oclif/core/lib/interfaces/parser").BooleanFlag<boolean>;
'dry-run': import("@oclif/core/lib/interfaces/parser").BooleanFlag<boolean>;
force: import("@oclif/core/lib/interfaces/parser").BooleanFlag<boolean>;
debug: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
'dry-run': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
force: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
};
}

@@ -13,2 +13,3 @@ "use strict";

const { flags: { debug, 'dry-run': dryRun, force }, } = await this.parse(Run);
await (0, _core_1.ensureAccessToken)(entrances);
if (!force) {

@@ -28,3 +29,2 @@ if (debug && !dryRun) {

}
await (0, _core_1.ensureAccessToken)(entrances);
await (0, _core_1.invoke)(entrances, { debug, dryRun });

@@ -31,0 +31,0 @@ this.exit();

{
"name": "@digshare/script",
"version": "0.4.0-1",
"version": "0.4.0",
"description": "DigShare Script SDK",
"repository": "https://github.com/digshare/digshare-script.git",
"license": "MIT",

@@ -13,7 +15,9 @@ "author": "Chengdu Enverse Technology Co., Ltd.",

"import": "./bld/library/esm/index.js",
"require": "./bld/library/cjs/index.js"
"require": "./bld/library/cjs/index.js",
"default": "./bld/library/esm/index.js"
},
"./x": {
"types": "./bld/x/index.d.ts",
"import": "./bld/x/index.js"
"import": "./bld/x/index.js",
"default": "./bld/x/index.js"
}

@@ -25,6 +29,7 @@ },

"scripts": {
"3": "pnpm install && pnpm dedupe && pnpm install",
"build": "rimraf ./bld && tsc --build",
"lint": "run-in-every eslint-project --parallel --echo -- eslint --config {configFileName} --no-error-on-unmatched-pattern .",
"lint": "eslint --no-error-on-unmatched-pattern . && run-in-every eslint-project --parallel --echo -- eslint --no-error-on-unmatched-pattern .",
"lint-prettier": "prettier --check .",
"test": "yarn lint-prettier && yarn build && yarn lint"
"test": "pnpm lint-prettier && pnpm build && pnpm lint"
},

@@ -39,31 +44,31 @@ "oclif": {

"@oclif/plugin-help": "^5",
"@rollup/plugin-commonjs": "^24.0.1",
"@rollup/plugin-commonjs": "^25.0.4",
"@rollup/plugin-json": "^6.0.0",
"@rollup/plugin-node-resolve": "^15.0.1",
"@rollup/plugin-terser": "^0.4.1",
"@rollup/plugin-node-resolve": "^15.2.0",
"@rollup/plugin-terser": "^0.4.3",
"@rollup/plugin-virtual": "^3.0.1",
"@types/ms": "^0.7.31",
"@types/prompts": "^2.4.3",
"@types/prompts": "^2.4.4",
"chalk": "4",
"enhanced-resolve": "^5.12.0",
"entrance-decorator": "^0.2.2",
"enhanced-resolve": "^5.15.0",
"entrance-decorator": "^0.2.5",
"ms": "^2.1.3",
"open": "^8.4.2",
"open": "8",
"pkg-dir": "5",
"prompts": "^2.4.2",
"rollup": "^3.19.1",
"tslib": "^2.5.0",
"undici": "^5.20.0",
"x-value": "^0.1.11"
"rollup": "^3.28.0",
"tslib": "^2.6.1",
"undici": "^5.23.0",
"x-value": "^0.1.14"
},
"devDependencies": {
"@mufan/code": "^0.2.16",
"@mufan/eslint-plugin": "^0.1.77",
"@types/node": "^18.15.0",
"eslint": "^8.36.0",
"prettier": "^2.8.4",
"rimraf": "^4.4.0",
"@mufan/eslint-plugin": "^0.1.81",
"@types/node": "^20.5.0",
"eslint": "^8.47.0",
"prettier": "^3.0.2",
"rimraf": "^5.0.1",
"run-in-every": "^0.2.0",
"typescript": "^4.9.5"
"typescript": "^5.1.6"
}
}
# 盯梢 {script}
```ts
import {script} from '@digshare/script';
为了方便频道主使用脚本发掘消息,盯梢提供了简洁明了的开发接口,频道主可以一键将脚本部署到云端,实现定时自动执行。
export default script(async (state = 0) => {
state++;
return {
message: `这是脚本自动发送的第 ${state} 条消息!`,
state,
};
});
```
## License
MIT License.
[脚本文档](https://docs.dingshao.cn/script)

@@ -27,3 +27,3 @@ import * as FS from 'fs';

readonly globalConfigPath: string,
readonly localConfigPath: string,
readonly localConfigPath: string | undefined,
) {

@@ -37,3 +37,6 @@ try {

try {
this.localRaw = JSON.parse(FS.readFileSync(localConfigPath, 'utf8'));
this.localRaw =
localConfigPath === undefined
? {}
: JSON.parse(FS.readFileSync(localConfigPath, 'utf8'));
} catch (error) {

@@ -66,7 +69,9 @@ this.localRaw = {};

FS.writeFileSync(
this.localConfigPath,
`${JSON.stringify(this.localRaw, undefined, 2)}\n`,
);
if (this.localConfigPath !== undefined) {
FS.writeFileSync(
this.localConfigPath,
`${JSON.stringify(this.localRaw, undefined, 2)}\n`,
);
}
}
}

@@ -8,1 +8,2 @@ export * from './pack';

export * from './invoke';
export * from './legacy';

@@ -1,2 +0,2 @@

import * as FS from 'fs';
import * as FS from 'fs/promises';
import * as Path from 'path';

@@ -15,6 +15,3 @@

const LOCAL_MAIN_FILE_PATH = Path.join(
__dirname,
'../../../res/local-main.mjs',
);
const LOCAL_MAIN_FILE_PATH = Path.join(__dirname, '../../../res/local-main.js');

@@ -78,2 +75,4 @@ function ROLLUP(entryCode: string, minify: boolean): Promise<RollupBuild> {

const mainFileContent = await FS.readFile(LOCAL_MAIN_FILE_PATH, 'utf8');
const build = await ROLLUP(

@@ -83,3 +82,3 @@ `\

${FS.readFileSync(LOCAL_MAIN_FILE_PATH, 'utf8')}`,
${mainFileContent}`,
false,

@@ -86,0 +85,0 @@ );

@@ -8,3 +8,6 @@ import * as Path from 'path';

export class Entrances {
constructor(readonly configDir: string, readonly projectDir: string) {}
constructor(
readonly configDir: string,
private projectDir: string | undefined,
) {}

@@ -14,6 +17,13 @@ /* eslint-disable @mufan/explicit-return-type */

@entrance
get workingDir() {
return this.projectDir ?? process.cwd();
}
@entrance
get config() {
return new Config(
Path.join(this.configDir, 'config.json'),
Path.join(this.projectDir, '.dssrc'),
this.projectDir === undefined
? undefined
: Path.join(this.projectDir, '.dssrc'),
);

@@ -20,0 +30,0 @@ }

@@ -16,3 +16,3 @@ import * as Path from 'path';

entrances,
entrances: {api, projectDir},
entrances: {api, workingDir},
} = this;

@@ -31,2 +31,4 @@

await ensureAccessToken(entrances);
if (!force) {

@@ -64,11 +66,9 @@ if (!debug) {

const {dss = {}} = require(Path.join(projectDir, 'package.json'));
const {dss = {}} = require(Path.join(workingDir, 'package.json'));
const {schedule} = ScriptOptions.exact().satisfies(dss);
await ensureAccessToken(entrances);
this.log('正在打包…');
const code = await pack(projectDir, {minify});
const code = await pack(workingDir, {minify});

@@ -75,0 +75,0 @@ this.log('正在部署…');

@@ -12,3 +12,3 @@ import * as ChildProcess from 'child_process';

const {
entrances: {projectDir},
entrances: {workingDir},
} = this;

@@ -20,3 +20,3 @@

const outScript = await packLocal(projectDir, Path.join(projectDir, out));
const outScript = await packLocal(workingDir, Path.join(workingDir, out));

@@ -23,0 +23,0 @@ ChildProcess.spawn(

@@ -15,6 +15,6 @@ import {Flags} from '@oclif/core';

await ensureAccessToken(entrances);
const startTime = last ? new Date(Date.now() - ms(last)) : undefined;
await ensureAccessToken(entrances);
for await (const event of pollLogs(entrances, {debug, startTime})) {

@@ -21,0 +21,0 @@ printLogEvent(event);

@@ -11,3 +11,3 @@ import * as Path from 'path';

const {
entrances: {projectDir},
entrances: {workingDir},
} = this;

@@ -21,8 +21,8 @@

const path = Path.join(projectDir, out);
const path = Path.join(workingDir, out);
await pack(projectDir, {out: path, minify});
await pack(workingDir, {out: path, minify});
this.log('打包成功!');
this.log('文件路径', Path.relative(projectDir, path));
this.log('文件路径', Path.relative(workingDir, path));

@@ -29,0 +29,0 @@ this.exit();

@@ -15,2 +15,4 @@ import {Flags} from '@oclif/core';

await ensureAccessToken(entrances);
if (!force) {

@@ -33,4 +35,2 @@ if (debug && !dryRun) {

await ensureAccessToken(entrances);
await invoke(entrances, {debug, dryRun});

@@ -37,0 +37,0 @@

@@ -6,3 +6,6 @@ import {ReadableStream} from 'stream/web';

export class API {
constructor(readonly endpoint: string, readonly accessToken: string) {}
constructor(
readonly endpoint: string,
readonly accessToken: string,
) {}

@@ -9,0 +12,0 @@ async call<TReturn extends object>(

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc