feat: add tm show (#1199)
This commit is contained in:
@@ -7,9 +7,8 @@
|
||||
"types": "./dist/tsup.base.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./src/tsup.base.ts",
|
||||
"import": "./dist/tsup.base.js",
|
||||
"require": "./dist/tsup.base.cjs"
|
||||
"types": "./dist/tsup.base.d.ts",
|
||||
"import": "./dist/tsup.base.js"
|
||||
}
|
||||
},
|
||||
"files": ["dist", "src"],
|
||||
@@ -17,15 +16,14 @@
|
||||
"author": "",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"build": "tsup",
|
||||
"dev": "tsup --watch",
|
||||
"build": "tsc",
|
||||
"typecheck": "tsc --noEmit"
|
||||
},
|
||||
"devDependencies": {
|
||||
"tsup": "^8.5.0",
|
||||
"dotenv-mono": "^1.5.1",
|
||||
"typescript": "^5.7.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"tsup": "^8.0.0"
|
||||
"dependencies": {
|
||||
"tsup": "^8.5.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,78 +3,56 @@
|
||||
* Provides shared configuration that can be extended by individual packages
|
||||
*/
|
||||
import type { Options } from 'tsup';
|
||||
import * as dotenv from 'dotenv-mono';
|
||||
|
||||
dotenv.load();
|
||||
|
||||
console.log(
|
||||
'TM_PUBLIC_BASE_DOMAIN:',
|
||||
process.env.TM_PUBLIC_BASE_DOMAIN,
|
||||
'TM_PUBLIC_SUPABASE_URL:',
|
||||
process.env.TM_PUBLIC_SUPABASE_URL,
|
||||
'TM_PUBLIC_SUPABASE_ANON_KEY:',
|
||||
process.env.TM_PUBLIC_SUPABASE_ANON_KEY
|
||||
);
|
||||
|
||||
const isProduction = process.env.NODE_ENV === 'production';
|
||||
const isDevelopment = !isProduction;
|
||||
|
||||
const envVariables = {
|
||||
TM_PUBLIC_BASE_DOMAIN: process.env.TM_PUBLIC_BASE_DOMAIN ?? '',
|
||||
TM_PUBLIC_SUPABASE_URL: process.env.TM_PUBLIC_SUPABASE_URL ?? '',
|
||||
TM_PUBLIC_SUPABASE_ANON_KEY: process.env.TM_PUBLIC_SUPABASE_ANON_KEY ?? ''
|
||||
};
|
||||
|
||||
console.log('envVariables:', envVariables);
|
||||
|
||||
/**
|
||||
* Base configuration for library packages (tm-core, etc.)
|
||||
* Environment helpers
|
||||
*/
|
||||
export const libraryConfig: Partial<Options> = {
|
||||
format: ['cjs', 'esm'],
|
||||
target: 'es2022',
|
||||
// Sourcemaps only in development to reduce production bundle size
|
||||
sourcemap: isDevelopment,
|
||||
clean: true,
|
||||
dts: true,
|
||||
// Enable optimizations in production
|
||||
splitting: isProduction,
|
||||
treeshake: isProduction,
|
||||
minify: isProduction,
|
||||
bundle: true,
|
||||
esbuildOptions(options) {
|
||||
options.conditions = ['module'];
|
||||
// Better source mapping in development only
|
||||
options.sourcesContent = isDevelopment;
|
||||
// Keep original names for better debugging in development
|
||||
options.keepNames = isDevelopment;
|
||||
},
|
||||
// Watch mode configuration for development
|
||||
watch: isDevelopment ? ['src'] : false
|
||||
export const env = {
|
||||
isProduction,
|
||||
isDevelopment,
|
||||
NODE_ENV: process.env.NODE_ENV || 'development',
|
||||
...envVariables
|
||||
};
|
||||
|
||||
/**
|
||||
* Base configuration for CLI packages
|
||||
* Base tsup configuration for all packages
|
||||
* Since everything gets bundled into root dist/ anyway, use consistent settings
|
||||
*/
|
||||
export const cliConfig: Partial<Options> = {
|
||||
export const baseConfig: Partial<Options> = {
|
||||
format: ['esm'],
|
||||
target: 'node18',
|
||||
splitting: false,
|
||||
// Sourcemaps only in development to reduce production bundle size
|
||||
sourcemap: isDevelopment,
|
||||
clean: true,
|
||||
dts: true,
|
||||
shims: true,
|
||||
// Enable minification in production for smaller bundles
|
||||
dts: false,
|
||||
minify: isProduction,
|
||||
treeshake: isProduction,
|
||||
esbuildOptions(options) {
|
||||
options.platform = 'node';
|
||||
// Better source mapping in development only
|
||||
options.sourcesContent = isDevelopment;
|
||||
// Keep original names for better debugging in development
|
||||
options.keepNames = isDevelopment;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Base configuration for executable bundles (root level)
|
||||
*/
|
||||
export const executableConfig: Partial<Options> = {
|
||||
format: ['esm'],
|
||||
target: 'node18',
|
||||
splitting: false,
|
||||
// Sourcemaps only in development to reduce production bundle size
|
||||
sourcemap: isDevelopment,
|
||||
clean: true,
|
||||
bundle: true, // Bundle everything into one file
|
||||
// Minify in production for smaller executables
|
||||
minify: isProduction,
|
||||
// Handle TypeScript imports transparently
|
||||
loader: {
|
||||
'.js': 'jsx',
|
||||
'.ts': 'ts'
|
||||
},
|
||||
// Don't bundle any other dependencies (auto-external all node_modules)
|
||||
external: [/^[^./]/],
|
||||
env: envVariables,
|
||||
esbuildOptions(options) {
|
||||
options.platform = 'node';
|
||||
// Allow importing TypeScript from JavaScript
|
||||
@@ -83,14 +61,18 @@ export const executableConfig: Partial<Options> = {
|
||||
options.sourcesContent = isDevelopment;
|
||||
// Keep original names for better debugging in development
|
||||
options.keepNames = isDevelopment;
|
||||
}
|
||||
},
|
||||
// Watch mode configuration for development
|
||||
watch: false
|
||||
};
|
||||
|
||||
/**
|
||||
* Common external modules that should not be bundled
|
||||
* Legacy external modules list - kept for backwards compatibility
|
||||
* Note: When using tsup-node, this is not needed as it automatically
|
||||
* excludes dependencies and peerDependencies from package.json
|
||||
*/
|
||||
export const commonExternals = [
|
||||
// Native Node.js modules
|
||||
// Native Node.js modules (for cases where tsup is used instead of tsup-node)
|
||||
'fs',
|
||||
'path',
|
||||
'child_process',
|
||||
@@ -119,6 +101,7 @@ export const commonExternals = [
|
||||
|
||||
/**
|
||||
* Utility function to merge configurations
|
||||
* Simplified for tsup-node usage
|
||||
*/
|
||||
export function mergeConfig(
|
||||
baseConfig: Partial<Options>,
|
||||
@@ -127,8 +110,6 @@ export function mergeConfig(
|
||||
return {
|
||||
...baseConfig,
|
||||
...overrides,
|
||||
// Merge arrays instead of overwriting
|
||||
external: [...(baseConfig.external || []), ...(overrides.external || [])],
|
||||
// Merge esbuildOptions
|
||||
esbuildOptions(options, context) {
|
||||
if (baseConfig.esbuildOptions) {
|
||||
@@ -140,12 +121,3 @@ export function mergeConfig(
|
||||
}
|
||||
} as Options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Environment helpers
|
||||
*/
|
||||
export const env = {
|
||||
isProduction,
|
||||
isDevelopment,
|
||||
NODE_ENV: process.env.NODE_ENV || 'development'
|
||||
};
|
||||
|
||||
@@ -6,9 +6,10 @@
|
||||
"moduleResolution": "bundler",
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"esModuleInterop": true,
|
||||
"baseUrl": ".",
|
||||
"outDir": "dist",
|
||||
"allowJs": true,
|
||||
"strict": true,
|
||||
"noEmit": true,
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"declaration": true,
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
import { defineConfig } from 'tsup';
|
||||
|
||||
const isProduction = process.env.NODE_ENV === 'production';
|
||||
|
||||
export default defineConfig({
|
||||
entry: ['src/tsup.base.ts'],
|
||||
format: ['esm', 'cjs'],
|
||||
target: 'node18',
|
||||
// Sourcemaps only in development
|
||||
sourcemap: !isProduction,
|
||||
clean: true,
|
||||
dts: true,
|
||||
// Enable minification in production
|
||||
minify: isProduction,
|
||||
treeshake: isProduction,
|
||||
external: ['tsup'],
|
||||
esbuildOptions(options) {
|
||||
// Better source mapping in development only
|
||||
options.sourcesContent = !isProduction;
|
||||
// Keep original names for better debugging in development
|
||||
options.keepNames = !isProduction;
|
||||
}
|
||||
});
|
||||
@@ -53,8 +53,8 @@
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsup",
|
||||
"dev": "tsup --watch",
|
||||
"build": "tsc",
|
||||
"dev": "tsc --watch",
|
||||
"test": "vitest run",
|
||||
"test:watch": "vitest",
|
||||
"test:coverage": "vitest run --coverage",
|
||||
@@ -71,18 +71,16 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@biomejs/biome": "^1.9.4",
|
||||
"@tm/build-config": "*",
|
||||
"@types/node": "^20.11.30",
|
||||
"@vitest/coverage-v8": "^2.0.5",
|
||||
"ts-node": "^10.9.2",
|
||||
"tsup": "^8.0.2",
|
||||
"typescript": "^5.4.3",
|
||||
"vitest": "^2.0.5"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18.0.0"
|
||||
},
|
||||
"files": ["dist", "README.md", "CHANGELOG.md"],
|
||||
"files": ["src", "README.md", "CHANGELOG.md"],
|
||||
"keywords": ["task-management", "typescript", "ai", "prd", "parser"],
|
||||
"author": "Task Master AI",
|
||||
"license": "MIT"
|
||||
|
||||
@@ -31,7 +31,7 @@ export class AuthManager {
|
||||
private organizationService?: OrganizationService;
|
||||
|
||||
private constructor(config?: Partial<AuthConfig>) {
|
||||
this.credentialStore = new CredentialStore(config);
|
||||
this.credentialStore = CredentialStore.getInstance(config);
|
||||
this.supabaseClient = new SupabaseAuthClient();
|
||||
this.oauthService = new OAuthService(this.credentialStore, config);
|
||||
|
||||
@@ -73,6 +73,7 @@ export class AuthManager {
|
||||
*/
|
||||
static resetInstance(): void {
|
||||
AuthManager.instance = null;
|
||||
CredentialStore.resetInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,15 +19,39 @@ import { getLogger } from '../logger/index.js';
|
||||
* human-readable persisted format in the auth.json file.
|
||||
*/
|
||||
export class CredentialStore {
|
||||
private static instance: CredentialStore | null = null;
|
||||
private logger = getLogger('CredentialStore');
|
||||
private config: AuthConfig;
|
||||
// Clock skew tolerance for expiry checks (30 seconds)
|
||||
private readonly CLOCK_SKEW_MS = 30_000;
|
||||
|
||||
constructor(config?: Partial<AuthConfig>) {
|
||||
private constructor(config?: Partial<AuthConfig>) {
|
||||
this.config = getAuthConfig(config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the singleton instance of CredentialStore
|
||||
*/
|
||||
static getInstance(config?: Partial<AuthConfig>): CredentialStore {
|
||||
if (!CredentialStore.instance) {
|
||||
CredentialStore.instance = new CredentialStore(config);
|
||||
} else if (config) {
|
||||
// Warn if config is provided after initialization
|
||||
const logger = getLogger('CredentialStore');
|
||||
logger.warn(
|
||||
'getInstance called with config after initialization; config is ignored.'
|
||||
);
|
||||
}
|
||||
return CredentialStore.instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the singleton instance (useful for testing)
|
||||
*/
|
||||
static resetInstance(): void {
|
||||
CredentialStore.instance = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get stored authentication credentials
|
||||
* @returns AuthCredentials with expiresAt as number (milliseconds) for runtime use
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
export { AuthManager } from './auth-manager.js';
|
||||
export { CredentialStore } from './credential-store.js';
|
||||
export { OAuthService } from './oauth-service.js';
|
||||
export { SupabaseSessionStorage } from './supabase-session-storage';
|
||||
export { SupabaseSessionStorage } from './supabase-session-storage.js';
|
||||
export type {
|
||||
Organization,
|
||||
Brief,
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
*/
|
||||
|
||||
import { SupportedStorage } from '@supabase/supabase-js';
|
||||
import { CredentialStore } from './credential-store';
|
||||
import { AuthCredentials } from './types';
|
||||
import { getLogger } from '../logger';
|
||||
import { CredentialStore } from './credential-store.js';
|
||||
import { AuthCredentials } from './types.js';
|
||||
import { getLogger } from '../logger/index.js';
|
||||
|
||||
const STORAGE_KEY = 'sb-taskmaster-auth-token';
|
||||
|
||||
|
||||
@@ -10,8 +10,8 @@ import {
|
||||
} from '@supabase/supabase-js';
|
||||
import { AuthenticationError } from '../auth/types.js';
|
||||
import { getLogger } from '../logger/index.js';
|
||||
import { SupabaseSessionStorage } from '../auth/supabase-session-storage';
|
||||
import { CredentialStore } from '../auth/credential-store';
|
||||
import { SupabaseSessionStorage } from '../auth/supabase-session-storage.js';
|
||||
import { CredentialStore } from '../auth/credential-store.js';
|
||||
|
||||
export class SupabaseAuthClient {
|
||||
private client: SupabaseJSClient | null = null;
|
||||
@@ -19,7 +19,7 @@ export class SupabaseAuthClient {
|
||||
private logger = getLogger('SupabaseAuthClient');
|
||||
|
||||
constructor() {
|
||||
const credentialStore = new CredentialStore();
|
||||
const credentialStore = CredentialStore.getInstance();
|
||||
this.sessionStorage = new SupabaseSessionStorage(credentialStore);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"module": "ESNext",
|
||||
"module": "NodeNext",
|
||||
"lib": ["ES2022"],
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
@@ -24,11 +24,12 @@
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"moduleResolution": "bundler",
|
||||
"moduleResolution": "NodeNext",
|
||||
"moduleDetection": "force",
|
||||
"types": ["node"],
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true
|
||||
"isolatedModules": true,
|
||||
"allowImportingTsExtensions": false
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules", "dist", "tests", "**/*.test.ts", "**/*.spec.ts"]
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
import { defineConfig } from 'tsup';
|
||||
import { libraryConfig, mergeConfig } from '@tm/build-config';
|
||||
|
||||
export default defineConfig(
|
||||
mergeConfig(libraryConfig, {
|
||||
entry: {
|
||||
index: 'src/index.ts',
|
||||
'auth/index': 'src/auth/index.ts',
|
||||
'config/index': 'src/config/index.ts',
|
||||
'services/index': 'src/services/index.ts',
|
||||
'logger/index': 'src/logger/index.ts',
|
||||
'interfaces/index': 'src/interfaces/index.ts',
|
||||
'types/index': 'src/types/index.ts',
|
||||
'providers/index': 'src/providers/index.ts',
|
||||
'storage/index': 'src/storage/index.ts',
|
||||
'parser/index': 'src/parser/index.ts',
|
||||
'utils/index': 'src/utils/index.ts',
|
||||
'errors/index': 'src/errors/index.ts'
|
||||
},
|
||||
tsconfig: './tsconfig.json',
|
||||
outDir: 'dist',
|
||||
external: ['zod', '@supabase/supabase-js']
|
||||
})
|
||||
);
|
||||
Reference in New Issue
Block a user