@fubar-it-co/tmdb-client 0.0.5

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.
package/publish.sh ADDED
@@ -0,0 +1,114 @@
1
+ #!/bin/bash
2
+
3
+ # Make the script executable in MacOS: chmod +x publish.sh
4
+
5
+ # You have to be logged in to npm before running this script.
6
+ # You have to have NPM_TOKEN in your .env file
7
+
8
+ # Colors for output
9
+ RED='\033[0;31m'
10
+ GREEN='\033[0;32m'
11
+ YELLOW='\033[1;33m'
12
+ NC='\033[0m' # No Color
13
+
14
+ # Set default version type to patch if not provided
15
+ VERSION_TYPE="${1:-patch}"
16
+
17
+ # Validate version type argument
18
+ if [[ ! "$VERSION_TYPE" =~ ^(patch|minor|major)$ ]]; then
19
+ echo -e "\033[0;31mError: Invalid version type. Must be one of: patch, minor, major\033[0m"
20
+ exit 1
21
+ fi
22
+
23
+ # Function to log messages
24
+ log() {
25
+ echo -e "${2:-$GREEN}$1${NC}"
26
+ }
27
+
28
+ # Function to check if command was successful
29
+ check_status() {
30
+ if [ $? -eq 0 ]; then
31
+ log "✓ $1 completed successfully"
32
+ else
33
+ log "✗ $1 failed" "$RED"
34
+ exit 1
35
+ fi
36
+ }
37
+ # Load environment variables from .env file (root of monorepo)
38
+ if [ -f ../../.env ]; then
39
+ log "Loading environment variables from .env file..." "$YELLOW"
40
+ export $(cat ../../.env | grep -v '^#' | xargs)
41
+ else
42
+ log ".env file not found at root. Please create one" "$RED"
43
+ exit 1
44
+ fi
45
+
46
+ # Check for NPM_TOKEN
47
+ if [ -z "$NPM_TOKEN" ]; then
48
+ log "NPM_TOKEN is not set in .env file" "$RED"
49
+ log "Please add your NPM_TOKEN to the .env file" "$YELLOW"
50
+ exit 1
51
+ fi
52
+
53
+ # Check git tags configuration
54
+ log "Configuring git..." "$YELLOW"
55
+ git config --local version.commitTag true
56
+ git config --local tag.gpgSign false
57
+ git config --local version.tagName "v%s"
58
+ check_status "Git configuration"
59
+
60
+ # Create or update .npmrc file with the token
61
+ log "Configuring npm authentication..." "$YELLOW"
62
+ cat > .npmrc << EOL
63
+ //registry.npmjs.org/:_authToken=${NPM_TOKEN}
64
+ registry=https://registry.npmjs.org/
65
+ @fubar-it-co:registry=https://registry.npmjs.org/
66
+ always-auth=true
67
+
68
+ # pnpm specific settings
69
+ strict-peer-dependencies=false
70
+ auto-install-peers=true
71
+ resolution-mode=highest
72
+ public-hoist-pattern[]=@storybook/*
73
+ EOL
74
+ check_status "NPM authentication configuration"
75
+
76
+ # Build
77
+ log "Building package..." "$YELLOW"
78
+ pnpm build
79
+ check_status "Build"
80
+
81
+ log "Creating new version..." "$YELLOW"
82
+ pnpm version "$VERSION_TYPE"
83
+ check_status "Version bump"
84
+
85
+ # Generate changelog
86
+ log "Generating changelog..." "$YELLOW"
87
+ pnpm exec conventional-changelog -p angular -r 0 > CHANGELOG.md
88
+ check_status "Changelog generation"
89
+
90
+ # Add changelog to git
91
+ git add CHANGELOG.md
92
+ git commit -m "docs(http-client): update changelog for version bump" --no-verify
93
+ check_status "Changelog commit"
94
+
95
+ log "Publishing package..." "$YELLOW"
96
+ npm publish --userconfig .npmrc --no-git-checks
97
+ check_status "Publish"
98
+
99
+ CURRENT_VERSION=$(node -p "require('./package.json').version")
100
+ log "Ensuring tag http-client-v${CURRENT_VERSION} exists..." "$YELLOW"
101
+ git tag -a "http-client-v${CURRENT_VERSION}" -m "http-client Version ${CURRENT_VERSION}" || true
102
+ check_status "Tag creation"
103
+
104
+ log "Pushing new version to repository..." "$YELLOW"
105
+ git push origin main && git push origin --tags
106
+ check_status "Git push"
107
+
108
+ # Clean up - remove .npmrc file and unset environment variables
109
+ log "Cleaning up..." "$YELLOW"
110
+ rm -f .npmrc
111
+ unset NPM_TOKEN
112
+ check_status "Cleanup"
113
+
114
+ log "🎉 Package published successfully!" "$GREEN"
@@ -0,0 +1,85 @@
1
+ /**
2
+ * @fileoverview Post-generation script to add @ts-nocheck to generated files
3
+ * and ensure TanStack Query exports are included.
4
+ *
5
+ * This script runs after heyAPI generates the client files.
6
+ * It adds `// @ts-nocheck` to the top of generated .ts files to prevent
7
+ * TypeScript errors from the generated code (e.g., duplicate Content-Type headers).
8
+ *
9
+ * Usage: Called automatically by `pnpm generate`
10
+ */
11
+ import { readdir, readFile, writeFile, stat } from 'node:fs/promises'
12
+ import { join } from 'node:path'
13
+ import { fileURLToPath } from 'node:url'
14
+
15
+ const __dirname = fileURLToPath(new URL('.', import.meta.url))
16
+ const clientDir = join(__dirname, '..', 'src', 'client')
17
+
18
+ async function processDirectory(dir, relativePath = '') {
19
+ const entries = await readdir(dir, { withFileTypes: true })
20
+
21
+ for (const entry of entries) {
22
+ const fullPath = join(dir, entry.name)
23
+
24
+ if (entry.isDirectory()) {
25
+ await processDirectory(fullPath, join(relativePath, entry.name))
26
+ } else if (entry.name.endsWith('.ts')) {
27
+ const content = await readFile(fullPath, 'utf-8')
28
+
29
+ // Skip if already has @ts-nocheck
30
+ if (content.includes('// @ts-nocheck')) {
31
+ continue
32
+ }
33
+
34
+ // Add @ts-nocheck after the auto-generated comment
35
+ let newContent = content.replace(
36
+ '// This file is auto-generated by @hey-api/openapi-ts',
37
+ '// This file is auto-generated by @hey-api/openapi-ts\n// @ts-nocheck'
38
+ )
39
+
40
+ // Fix imports from .ts to .js for compiled files
41
+ newContent = newContent.replace(/from ['"]([^'"]+)\.ts['"]/g, "from '$1.js'")
42
+
43
+ await writeFile(fullPath, newContent, 'utf-8')
44
+ console.log(`Added @ts-nocheck to ${join(relativePath, entry.name)}`)
45
+ }
46
+ }
47
+ }
48
+
49
+ async function addTanStackQueryExport() {
50
+ const indexPath = join(clientDir, 'index.ts')
51
+ const tanstackDir = join(clientDir, '@tanstack')
52
+
53
+ try {
54
+ await stat(tanstackDir)
55
+ } catch {
56
+ console.log('No @tanstack directory found, skipping export addition')
57
+ return
58
+ }
59
+
60
+ const content = await readFile(indexPath, 'utf-8')
61
+
62
+ // Check if already exported
63
+ if (content.includes('@tanstack/react-query.gen')) {
64
+ console.log('TanStack Query already exported')
65
+ return
66
+ }
67
+
68
+ // Add export for TanStack Query
69
+ const newContent = content + "export * from './@tanstack/react-query.gen'\n"
70
+ await writeFile(indexPath, newContent, 'utf-8')
71
+ console.log('Added TanStack Query export to index.ts')
72
+ }
73
+
74
+ async function main() {
75
+ try {
76
+ await processDirectory(clientDir)
77
+ await addTanStackQueryExport()
78
+ console.log('Done!')
79
+ } catch (error) {
80
+ console.error('Error in post-generation script:', error)
81
+ process.exit(1)
82
+ }
83
+ }
84
+
85
+ main()