forge-sql-orm 1.0.20 → 1.0.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,7 +8,7 @@ const os = require("os");
8
8
  const args = process.argv.slice(2).join(" ");
9
9
 
10
10
  // Resolve the path to cli.ts (your TypeScript entry file)
11
- const cliPath = path.resolve(__dirname, "cli.cjs");
11
+ const cliPath = path.resolve(__dirname, "cli.js");
12
12
 
13
13
  // Function to run a command
14
14
  const runCommand = (cmd) => {
@@ -21,27 +21,4 @@ const runCommand = (cmd) => {
21
21
  }
22
22
  };
23
23
 
24
- // **1. Check if `ts-node` is globally installed**
25
- const isGlobalTsNodeInstalled = (() => {
26
- try {
27
- execSync("ts-node --version", { stdio: "ignore" }); // Check if `ts-node` runs without error
28
- return true;
29
- } catch {
30
- return false;
31
- }
32
- })();
33
-
34
- if (isGlobalTsNodeInstalled) {
35
- console.log("✅ Using global ts-node");
36
- runCommand(`node -r ts-node/register ${cliPath} ${args}`);
37
- }
38
-
39
- // **2. If not, check for local ts-node**
40
- if (fs.existsSync(localTsNode)) {
41
- console.log("✅ Using local ts-node");
42
- runCommand(`"${localTsNode}" ${cliPath} ${args}`);
43
- }
44
-
45
- // **3. If neither found, fallback to npx**
46
- console.warn("⚠️ Neither global nor local ts-node found, using npx...");
47
- runCommand(`npx node -r ts-node/register ${cliPath} ${args}`);
24
+ runCommand(`node ./tsm/bin.js cli.js ${cliPath} ${args}`);
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env node
2
+ "use strict";let argv=process.argv.slice(2);if(argv.includes("-h")||argv.includes("--help")){let e="";e+=`
3
+ Usage
4
+ $ tsm [options] -- <command>
5
+ `,e+=`
6
+ Options`,e+=`
7
+ --tsmconfig Configuration file path (default: tsm.js)`,e+=`
8
+ --quiet Silence all terminal messages`,e+=`
9
+ --version Displays current version`,e+=`
10
+ --help Displays this message
11
+ `,e+=`
12
+ Examples`,e+=`
13
+ $ tsm server.ts`,e+=`
14
+ $ node -r tsm input.jsx`,e+=`
15
+ $ node --loader tsm input.jsx`,e+=`
16
+ $ NO_COLOR=1 tsm input.jsx --trace-warnings`,e+=`
17
+ $ tsm server.tsx --tsmconfig tsm.mjs
18
+ `,console.log(e),process.exit(0)}(argv.includes("-v")||argv.includes("--version"))&&(console.log("tsm, v2.3.0"),process.exit(0));let{URL,pathToFileURL}=require("url");argv=["--enable-source-maps","--loader",new URL("loader.mjs",pathToFileURL(__filename)).href,...argv],require("child_process").spawn("node",argv,{stdio:"inherit"}).on("exit",process.exit);
@@ -0,0 +1,22 @@
1
+ import type { Loader, TransformOptions } from 'esbuild';
2
+
3
+ export type Extension = `.${string}`;
4
+ export type Options = TransformOptions;
5
+
6
+ export type Config = {
7
+ [extn: Extension]: Options;
8
+ }
9
+
10
+ export type ConfigFile =
11
+ | { common?: Options; config?: Config; loaders?: never; [extn: Extension]: never }
12
+ | { common?: Options; loaders?: Loaders; config?: never; [extn: Extension]: never }
13
+ | { common?: Options; config?: never; loaders?: never; [extn: Extension]: Options }
14
+
15
+ export type Loaders = {
16
+ [extn: Extension]: Loader;
17
+ }
18
+
19
+ /**
20
+ * TypeScript helper for writing `tsm.js` contents.
21
+ */
22
+ export function define(contents: ConfigFile): ConfigFile;
@@ -0,0 +1 @@
1
+ exports.define=c=>c;
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) Luke Edwards <luke.edwards05@gmail.com> (lukeed.com)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1 @@
1
+ "use strict";import{existsSync as j,promises as S}from"fs";import{fileURLToPath as d,URL as h}from"url";import*as y from"./utils.js";let u,m,c=y.$defaults("esm"),T=c.file&&import("file:///"+c.file);async function x(){let t=await T;return t=t&&t.default||t,y.$finalize(c,t)}const w=/\.\w+(?=\?|$)/,b=/\.[mc]?tsx?(?=\?|$)/;async function p(t){u=u||await x();let[r]=w.exec(t)||[];return u[r]}function g(t){let r=d(t);if(j(r))return t}const C={".js":[".ts",".tsx",".jsx"],".jsx":[".tsx"],".mjs":[".mts"],".cjs":[".cts"]},R=new h("file:///"+process.cwd()+"/");export const resolve=async function(t,r,o){if(/^\w+\:?/.test(t))return o(t,r,o);let e=new h(t,r.parentURL||R),s,n,l,i,a=0,f;if(i=w.exec(e.href)){if(s=i[0],!r.parentURL||b.test(s))return{url:e.href,shortCircuit:!0};if(n=g(e.href))return{url:n,shortCircuit:!0};if(l=C[s]){for(f=e.href.substring(0,i.index);a<l.length;a++)if(n=g(f+l[a]))return a=i.index+s.length,{shortCircuit:!0,url:a>e.href.length?f+e.href.substring(a):n}}return o(t,r,o)}u=u||await x();for(s in u)if(n=g(e.href+s),n)return{url:n,shortCircuit:!0};return o(t,r,o)},load=async function(t,r,o){let e=await p(t);if(e==null)return o(t,r,o);let s=e.format==="cjs"?"commonjs":"module",n=d(t),l=await S.readFile(n);m=m||await import("esbuild");let i=await m.transform(l.toString(),{...e,sourcefile:n,format:s==="module"?"esm":"cjs"});return{format:s,source:i.code,shortCircuit:!0}},getFormat=async function(t,r,o){let e=await p(t);return e==null?o(t,r,o):{format:e.format==="cjs"?"commonjs":"module"}},transformSource=async function(t,r,o){let e=await p(r.url);return e==null?o(t,r,o):(m=m||await import("esbuild"),{source:(await m.transform(t.toString(),{...e,sourcefile:r.url,format:r.format==="module"?"esm":"cjs"})).code})};
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "tsm",
3
+ "version": "2.3.0",
4
+ "repository": "lukeed/tsm",
5
+ "description": "TypeScript Module Loader",
6
+ "license": "MIT",
7
+ "bin": "bin.js",
8
+ "author": {
9
+ "name": "Luke Edwards",
10
+ "email": "luke.edwards05@gmail.com",
11
+ "url": "https://lukeed.com"
12
+ },
13
+ "exports": {
14
+ ".": {
15
+ "import": "./loader.mjs",
16
+ "require": "./require.js"
17
+ },
18
+ "./config": "./config/index.js",
19
+ "./package.json": "./package.json"
20
+ },
21
+ "files": [
22
+ "bin.js",
23
+ "utils.js",
24
+ "require.js",
25
+ "loader.mjs",
26
+ "config"
27
+ ],
28
+ "engines": {
29
+ "node": ">=12"
30
+ },
31
+ "scripts": {
32
+ "build": "node build",
33
+ "types": "tsc --skipLibCheck"
34
+ },
35
+ "dependencies": {
36
+ "esbuild": "^0.15.16"
37
+ },
38
+ "devDependencies": {
39
+ "@types/node": "16.11.6",
40
+ "@types/react": "17.0.33",
41
+ "typescript": "4.9.3"
42
+ },
43
+ "keywords": [
44
+ "esm",
45
+ "loader",
46
+ "typescript",
47
+ "loader hook",
48
+ "require hook",
49
+ "experimental-loader"
50
+ ]
51
+ }
@@ -0,0 +1,62 @@
1
+ <div align="center">
2
+ <img src="logo.png" alt="tsm" width="200" />
3
+ </div>
4
+
5
+ <div align="center">
6
+ <a href="https://npmjs.org/package/tsm">
7
+ <img src="https://badgen.net/npm/v/tsm" alt="version" />
8
+ </a>
9
+ <a href="https://github.com/lukeed/tsm/actions">
10
+ <img src="https://github.com/lukeed/tsm/workflows/CI/badge.svg" alt="CI" />
11
+ </a>
12
+ <a href="https://npmjs.org/package/tsm">
13
+ <img src="https://badgen.net/npm/dm/tsm" alt="downloads" />
14
+ </a>
15
+ <a href="https://packagephobia.now.sh/result?p=tsm">
16
+ <img src="https://badgen.net/packagephobia/publish/tsm" alt="publish size" />
17
+ </a>
18
+ </div>
19
+
20
+ <div align="center">TypeScript Module Loader</div>
21
+
22
+ ## Features
23
+
24
+ * Supports `node <file>` usage
25
+ * Supports [ESM `--loader`](https://nodejs.org/api/esm.html#esm_loaders) usage<sup>†</sup>
26
+ * Supports [`--require` hook](https://nodejs.org/api/cli.html#cli_r_require_module) usage
27
+ * Optional [configuration](/docs/configuration.md) file for per-extension customization
28
+
29
+ > <sup>†</sup> The ESM Loader API is still **experimental** and will change in the future.
30
+
31
+ ## Install
32
+
33
+ ```sh
34
+ # install as project dependency
35
+ $ npm install --save-dev tsm
36
+
37
+ # or install globally
38
+ $ npm install --global tsm
39
+ ```
40
+
41
+ ## Usage
42
+
43
+ > **Note:** Refer to [`/docs/usage.md`](/docs/usage.md) for more information.
44
+
45
+ ```sh
46
+ # use as `node` replacement
47
+ $ tsm server.ts
48
+
49
+ # forwards any `node` ENV or flags
50
+ $ NO_COLOR=1 tsm server.ts --trace-warnings
51
+
52
+ # use as `--require` hook
53
+ $ node --require tsm server.tsx
54
+ $ node -r tsm server.tsx
55
+
56
+ # use as `--loader` hook
57
+ $ node --loader tsm main.jsx
58
+ ```
59
+
60
+ ## License
61
+
62
+ MIT © [Luke Edwards](https://lukeed.com)
@@ -0,0 +1 @@
1
+ "use strict";const{readFileSync}=require("fs"),{extname}=require("path"),tsm=require("./utils"),loadJS=require.extensions[".js"];let esbuild,env=tsm.$defaults("cjs"),uconf=env.file&&require(env.file),config=tsm.$finalize(env,uconf);const tsrequire='var $$req=require("module").createRequire(__filename);require=('+function(){let{existsSync:t}=$$req("fs"),r=$$req("url");return new Proxy(require,{apply(l,n,o){let[e]=o;if(!e)return l.apply(n||$$req,o);if(/^\w+\:?/.test(e))return $$req(e);let u=/\.([mc])?[tj]sx?(?=\?|$)/.exec(e);if(u==null)return $$req(e);let f=r.pathToFileURL(__filename),s=r.fileURLToPath(new r.URL(e,f));if(t(s))return $$req(e);let p=u[0],a=new RegExp(p+"$"),i=s.replace(a,p.replace("js","ts"));return t(i)||p===".js"&&(i=s.replace(a,".tsx"),t(i)||(i=s.replace(a,".jsx"),t(i)))?$$req(i):$$req(e)}})}+")();";function transform(t,r){return esbuild=esbuild||require("esbuild"),esbuild.transformSync(t,r).code}function loader(t,r){let l=extname(r),n=config[l]||{},o=t._compile.bind(t);n.sourcefile=r,/\.[mc]?[tj]sx?$/.test(l)&&(n.banner=tsrequire+(n.banner||""),n.supported=n.supported||{},n.supported["dynamic-import"]=!1),config[l]!=null&&(t._compile=e=>{let u=transform(e,n);return o(u,r)});try{return loadJS(t,r)}catch(e){if((e&&e.code)!=="ERR_REQUIRE_ESM")throw e;let f=readFileSync(r,"utf8"),s=transform(f,{...n,format:"cjs"});return o(s,r)}}for(let t in config)require.extensions[t]=loader;config[".js"]==null&&(require.extensions[".js"]=loader);
@@ -0,0 +1 @@
1
+ "use strict";const{resolve}=require("path"),{existsSync}=require("fs");exports.$defaults=function(l){let{FORCE_COLOR:e,NO_COLOR:s,NODE_DISABLE_COLORS:o,TERM:t}=process.env,i=process.argv.slice(2),n=new Set(i),f=n.has("-q")||n.has("--quiet"),d=!o&&s==null&&t!=="dumb"&&(e!=null&&e!=="0"||process.stdout.isTTY),r=n.has("--tsmconfig")?i.indexOf("--tsmconfig"):-1,a=resolve(".",!!~r&&i[++r]||"tsm.js");return{file:existsSync(a)&&a,isESM:l==="esm",options:{format:l,charset:"utf8",sourcemap:"inline",target:"node"+process.versions.node,logLevel:f?"silent":"warning",color:d}}},exports.$finalize=function(l,e){let s=l.options;e&&e.common&&(Object.assign(s,e.common),delete e.common);let o={".mts":{...s,loader:"ts"},".jsx":{...s,loader:"jsx"},".tsx":{...s,loader:"tsx"},".cts":{...s,loader:"ts"},".ts":{...s,loader:"ts"}};l.isESM?o[".json"]={...s,loader:"json"}:o[".mjs"]={...s,loader:"js"};let t;if(e&&e.loaders)for(t in e.loaders)o[t]={...s,loader:e.loaders[t]};else if(e){let i=e.config||e;for(t in i)o[t]={...s,...i[t]}}return o};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "forge-sql-orm",
3
- "version": "1.0.20",
3
+ "version": "1.0.21",
4
4
  "description": "Mikro-ORM integration for Forge-SQL in Atlassian Forge applications.",
5
5
  "main": "dist/ForgeSQLORM.js",
6
6
  "module": "dist/ForgeSQLORM.mjs",
package/dist-cli/.env DELETED
@@ -1,7 +0,0 @@
1
- export FORGE_SQL_ORM_HOST=localhost
2
- export FORGE_SQL_ORM_PORT=3366
3
- export FORGE_SQL_ORM_USER=root
4
- export FORGE_SQL_ORM_PASSWORD=admin
5
- export FORGE_SQL_ORM_DBNAME=forgesqlorm
6
- export FORGE_SQL_ORM_OUTPUT=src/migration
7
- export FORGE_SQL_ORM_ENTITIES_PATH=src/entities
@@ -1,14 +0,0 @@
1
- import { EntitySchema } from '@mikro-orm/mysql';
2
-
3
- export class Users {
4
- id!: number;
5
- name?: string;
6
- }
7
-
8
- export const UsersSchema = new EntitySchema({
9
- class: Users,
10
- properties: {
11
- id: { primary: true, type: 'integer', unsigned: false },
12
- name: { type: 'string', length: 200, nullable: true },
13
- },
14
- });
@@ -1,3 +0,0 @@
1
- import { Users } from "./Users";
2
-
3
- export default [Users];