tickerowl-app-base
Advanced tools
Comparing version 1.0.6 to 1.0.7
#!/usr/bin/env node | ||
declare function loadModule(moduleName: string): Promise<any>; | ||
declare const args: string[]; | ||
export {}; |
@@ -35,2 +35,8 @@ #!/usr/bin/env node | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const fs_1 = __importDefault(require("fs")); | ||
const path_1 = __importDefault(require("path")); | ||
function loadModule(moduleName) { | ||
@@ -40,17 +46,74 @@ return __awaiter(this, void 0, void 0, function* () { | ||
const module = yield Promise.resolve(`${moduleName}`).then(s => __importStar(require(s))); | ||
console.log('Module loaded:', module); | ||
return module.default; | ||
} | ||
catch (error) { | ||
console.error('Error loading module:', error); | ||
console.error("Error loading module:", error); | ||
} | ||
}); | ||
} | ||
function loadInputs() { | ||
if (fs_1.default.existsSync(path_1.default.join(process.cwd(), "run-inputs.json"))) { | ||
try { | ||
const fileContents = fs_1.default.readFileSync("run-inputs.json", "utf8"); | ||
return JSON.parse(fileContents); | ||
} | ||
catch (error) { | ||
console.log("No inputs file found, using empty object. Create a run-inputs.json file to pass inputs to the app."); | ||
} | ||
} | ||
return {}; | ||
} | ||
const args = process.argv.slice(2); | ||
const storeData = {}; | ||
class DummyStore { | ||
read(key) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return storeData[key]; | ||
}); | ||
} | ||
write(key, value) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
storeData[key] = value; | ||
}); | ||
} | ||
delete(key) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
delete storeData[key]; | ||
}); | ||
} | ||
list(prefix) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return Object.keys(storeData).filter((key) => key.startsWith(prefix)); | ||
}); | ||
} | ||
} | ||
(() => __awaiter(void 0, void 0, void 0, function* () { | ||
const path = require('path'); | ||
const path = require("path"); | ||
const [modulePath] = args; | ||
const store = new DummyStore(); | ||
const currentWorkingDirectory = process.cwd(); | ||
const cls = yield loadModule(path.join(currentWorkingDirectory, args[0])); | ||
const cls = yield loadModule(path.join(currentWorkingDirectory, modulePath)); | ||
const app = new cls(); | ||
console.log(app.getInfo()); | ||
const allInputs = loadInputs(); | ||
Object.entries(app.getSlides()).forEach((_a) => __awaiter(void 0, [_a], void 0, function* ([key, slide]) { | ||
console.log(">>>>>>"); | ||
console.log("Running slide", key, "with inputs", allInputs[key]); | ||
const result = yield slide.getData({ | ||
inputs: Object.fromEntries(Object.entries(slide.inputs).map(([inputKey, value]) => { | ||
var _a; | ||
return [ | ||
inputKey, | ||
{ | ||
input: value, | ||
value: { | ||
value: ((_a = allInputs[key]) !== null && _a !== void 0 ? _a : {})[inputKey], | ||
}, | ||
} | ||
]; | ||
})), | ||
store, | ||
}); | ||
console.log("Result", result); | ||
})); | ||
}))(); |
{ | ||
"name": "tickerowl-app-base", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -14,3 +14,3 @@ # TickerOwl App SDK | ||
1. Make new directory for your app. `mkdir my-app && cd my-app` | ||
2. Initiate npm project `npm init -y` | ||
2. Initiate npm project `npm init` & make sure the name starts with `tickerowl-` | ||
3. Install & setup typescript `npm install -D typescript` & `npx tsc --init` | ||
@@ -17,0 +17,0 @@ 4. Install `tickerowl-app-base` package `npm install tickerowl-app-base` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10553
242
3