diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..0f2835a --- /dev/null +++ b/.npmignore @@ -0,0 +1,4 @@ +src +tests +rollup.config.js +tsconfig.json diff --git a/dist/index.cjs.js b/dist/index.cjs.js new file mode 100644 index 0000000..6ab9717 --- /dev/null +++ b/dist/index.cjs.js @@ -0,0 +1,16 @@ +'use strict'; + +class Updater { + archiveURL; + feedType; + constructor(archiveURL = "/", feedType = "rss") { + this.archiveURL = archiveURL; + this.feedType = feedType; + } + async getArchive() { + const res = await fetch(`${this.archiveURL}.${this.feedType}`); + console.log(res); + } +} + +module.exports = Updater; diff --git a/dist/index.d.ts b/dist/index.d.ts new file mode 100644 index 0000000..8a63322 --- /dev/null +++ b/dist/index.d.ts @@ -0,0 +1,6 @@ +export default class Updater { + archiveURL: string; + feedType: string; + constructor(archiveURL?: string, feedType?: string); + getArchive(): Promise; +} diff --git a/dist/index.es.js b/dist/index.es.js new file mode 100644 index 0000000..3ac7d62 --- /dev/null +++ b/dist/index.es.js @@ -0,0 +1,14 @@ +class Updater { + archiveURL; + feedType; + constructor(archiveURL = "/", feedType = "rss") { + this.archiveURL = archiveURL; + this.feedType = feedType; + } + async getArchive() { + const res = await fetch(`${this.archiveURL}.${this.feedType}`); + console.log(res); + } +} + +export { Updater as default }; diff --git a/package.json b/package.json new file mode 100644 index 0000000..2d6bd5f --- /dev/null +++ b/package.json @@ -0,0 +1,36 @@ +{ + "name": "updaterweblibrary", + "version": "1.0.0", + "description": "OTA Updater App frontend library", + "repository": { + "type": "git", + "url": "git@git.emaker.limited:MicrocontrollerCD/UpdaterWebLibrary.git" + }, + "license": "MIT", + "author": "chopster44", + "type": "commonjs", + "main": "./dist/cjs/index.js", + "module": "./dist/esm/index.js", + "types": "./dist/types/index.d.ts", + "exports": { + ".": { + "require": "./dist/cjs/index.js", + "import": "./dist/esm/index.js" + } + }, + "files": [ + "dist" + ], + "scripts": { + "build:types": "tsc -p tsconfig.json --emitDeclarationOnly", + "build": "rm -rf ./dist && npm run build:types && rollup -c", + "test": "echo \"Error: no test specified\" && exit 1" + }, + "devDependencies": { + "@rollup/plugin-typescript": "^12.1.4", + "rollup": "^4.52.5", + "tslib": "^2.8.1", + "typescript": "^5.9.3", + "vitest": "^3.2.4" + } +} diff --git a/rollup.config.js b/rollup.config.js new file mode 100644 index 0000000..bec6ce1 --- /dev/null +++ b/rollup.config.js @@ -0,0 +1,23 @@ +const typescript = require("@rollup/plugin-typescript"); + +const typescriptOptions = { + exclude: ["tests/**/*"], + compilerOptions: { declaration: false }, +}; + +const data = [ + { + external: ["typeorm", "sinon"], + input: "src/index.ts", + output: { file: "dist/index.es.js", format: "esm" }, + plugins: [typescript(typescriptOptions)], + }, + { + external: ["typeorm", "sinon"], + input: "src/index.ts", + output: { file: "dist/index.cjs.js", format: "cjs" }, + plugins: [typescript(typescriptOptions)], + }, +]; + +module.exports = data; diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..fdc4eec --- /dev/null +++ b/src/index.ts @@ -0,0 +1,14 @@ +export default class Updater { + public archiveURL: string; + public feedType: string; + constructor(archiveURL: string = "/", feedType: string = "rss") { + this.archiveURL = archiveURL; + this.feedType = feedType; + } + + async getArchive(): Promise { + const res = await fetch(`${this.archiveURL}.${this.feedType}`); + console.log(res); + } +} + diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..0d1c517 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "target": "ES2022", + "module": "ESNext", + "moduleResolution": "Node", + "esModuleInterop": true, + "outDir": "./dist", + "strict": false, + "declaration": true, + "declarationDir": "./dist", + "paths": { + "rollup/parseAst": ["./node_modules/rollup/dist/parseAst"] + } + }, + "include": ["src/**/*"], + "exclude": ["node_modules"] +}