Răsfoiți Sursa

add publish script

painor 4 ani în urmă
părinte
comite
4eb6fb0cf1
3 a modificat fișierele cu 47 adăugiri și 10 ștergeri
  1. 9 9
      package-lock.json
  2. 1 1
      package.json
  3. 37 0
      publish_npm.js

+ 9 - 9
package-lock.json

@@ -1,12 +1,12 @@
 {
   "name": "telegram",
-  "version": "1.2.7",
+  "version": "1.4.3",
   "lockfileVersion": 2,
   "requires": true,
   "packages": {
     "": {
       "name": "telegram",
-      "version": "1.2.7",
+      "version": "1.4.3",
       "license": "MIT",
       "dependencies": {
         "@cryptography/aes": "^0.1.1",
@@ -38,7 +38,7 @@
         "raw-loader": "^4.0.2",
         "ts-loader": "^8.0.16",
         "ts-node": "^9.1.1",
-        "typescript": "^4.1.4",
+        "typescript": "^4.2.4",
         "webpack": "^5.21.2",
         "webpack-cli": "^4.5.0"
       }
@@ -11097,9 +11097,9 @@
       }
     },
     "node_modules/typescript": {
-      "version": "4.1.4",
-      "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.1.4.tgz",
-      "integrity": "sha512-+Uru0t8qIRgjuCpiSPpfGuhHecMllk5Zsazj5LZvVsEStEjmIRRBZe+jHjGQvsgS7M1wONy2PQXd67EMyV6acg==",
+      "version": "4.2.4",
+      "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.2.4.tgz",
+      "integrity": "sha512-V+evlYHZnQkaz8TRBuxTA92yZBPotr5H+WhQ7bD3hZUndx5tGOa1fuCgeSjxAzM1RiN5IzvadIXTVefuuwZCRg==",
       "dev": true,
       "bin": {
         "tsc": "bin/tsc",
@@ -21308,9 +21308,9 @@
       }
     },
     "typescript": {
-      "version": "4.1.4",
-      "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.1.4.tgz",
-      "integrity": "sha512-+Uru0t8qIRgjuCpiSPpfGuhHecMllk5Zsazj5LZvVsEStEjmIRRBZe+jHjGQvsgS7M1wONy2PQXd67EMyV6acg==",
+      "version": "4.2.4",
+      "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.2.4.tgz",
+      "integrity": "sha512-V+evlYHZnQkaz8TRBuxTA92yZBPotr5H+WhQ7bD3hZUndx5tGOa1fuCgeSjxAzM1RiN5IzvadIXTVefuuwZCRg==",
       "dev": true
     },
     "unicode-canonical-property-names-ecmascript": {

+ 1 - 1
package.json

@@ -33,7 +33,7 @@
     "raw-loader": "^4.0.2",
     "ts-loader": "^8.0.16",
     "ts-node": "^9.1.1",
-    "typescript": "^4.1.4",
+    "typescript": "^4.2.4",
     "webpack": "^5.21.2",
     "webpack-cli": "^4.5.0"
   },

+ 37 - 0
publish_npm.js

@@ -0,0 +1,37 @@
+const { exec } = require('child_process')
+const fs = require('fs')
+const tsc = exec('tsc')
+tsc.on('close', (code) => {
+    if (code === 0) {
+        fs.copyFileSync('package.json', 'dist/package.json')
+        fs.copyFileSync('README.md', 'dist/README.md')
+        fs.copyFileSync('LICENSE', 'dist/LICENSE')
+        if (!fs.existsSync('dist/tl/static')) {
+            fs.mkdirSync('dist/tl/static')
+        }
+        fs.copyFileSync('gramjs/tl/static/api.tl', 'dist/tl/static/api.tl')
+        fs.copyFileSync('gramjs/tl/static/schema.tl', 'dist/tl/static/schema.tl')
+        fs.copyFileSync('gramjs/tl/api.d.ts', 'dist/tl/api.d.ts')
+        fs.copyFileSync('gramjs/define.d.ts', 'dist/define.d.ts')
+        const npm_publish = exec('npm publish', { cwd: 'dist' })
+        npm_publish.stdout.on('data', function(data) {
+            console.log(data.toString())
+        })
+
+        npm_publish.stderr.on('data', function(data) {
+            console.error(data.toString())
+        })
+
+        npm_publish.on('close', (code) => {
+            if (code === 0) {
+                console.log('=====================================')
+                console.log('FINISHED UPLOADING')
+                console.log('=====================================')
+            }else{
+                throw new ERro
+            }
+        })
+    } else {
+        throw new Error('Error happened')
+    }
+})