Skip to content

Feat monorepo init#6

Open
shaiknoorullah wants to merge 54 commits intosshield-v2from
feat-monorepo-init
Open

Feat monorepo init#6
shaiknoorullah wants to merge 54 commits intosshield-v2from
feat-monorepo-init

Conversation

@shaiknoorullah
Copy link
Copy Markdown
Owner

@shaiknoorullah shaiknoorullah commented Aug 15, 2025

This is the initialization of monorepo setup for v2. please go through the README.md and ROADMAP.md for the updated plans.

New:

  • a config package has been initialized with basic configurations for

    • eslint
    • mocha
    • nyc (not working currently, need to change to c8)
    • prettier
    • tsup
    • tsconfig
  • nx has been initialized with a basic nx.json (also not tested and finalized, needs work)

  • cz has been initialized but is not in used (needs to be enhanced and enabled)

Pending/NYI

  • The config package needs to be more complete and need to find out a better way to use the tsconfigs defined in that package
  • need to change nyc to c8 and integrate with mocha/chai for test coverages + add badges for the same in README.md
  • initilize fumadocs for documentation website
  • complete monorepo setup.
    • nx configuration
    • package/plugin templates
    • husky, git-cz, commitlint, lintstaged configuration
    • semantic releases and versioning with release-it
    • automated CI with github actions
    • set PR and ISSUE templates

Additional Notes for Peer Contributors:

@shettydev please update your nx PR with the new target branch for v2 instead of main. checkout to sshield-v2 and take a pull then update your nx config.

@shaiknoorullah shaiknoorullah self-assigned this Aug 15, 2025
@shaiknoorullah shaiknoorullah changed the base branch from main to sshield-v2 August 15, 2025 16:10
Comment on lines +14 to +21
| P0 | #41 | Basic Monorepo Structure | None | 🔥🔥🔥 |
| P0 | #29 | Build & Packaging | #41 | 🔥🔥🔥 |
| P0 | #43 | Simple Config Management | #41 | 🔥🔥🔥 |
| P0 | #19 | Basic Security Hardening | #43 | 🔥🔥🔥 |
| P0 | #20 | SSH Key Management | #43, #19 | 🔥🔥🔥 |
| P0 | #12 | Server Bootstrap | #20, #43 | 🔥🔥 |
| P1 | #5 | File Transfer & Sync | #20 | 🔥🔥 |
| P1 | #9 | Basic Log Monitoring | #20 | 🔥🔥 |
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these issues exist?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope. we'll need to create them. also, these are very vague so I was hoping if you could help me clean this ROADMAP up and make it more clear and specific towards the feature set.

as for the project management. It would be best if we use the built in github Issues, Projects, Discussions, etc. I've enabled those features.

Comment on lines +36 to +42
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-unused-vars": [
"warn",
{ argsIgnorePattern: "^_" },
],
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure you don't want these to be strict? I would suggest an "error" instead of "off"

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these are just to get this monorepo init. will definitely need to revisit. I'd encourage you to go through and update all the configs. in the upcoming PRs

shaiknoorullah and others added 23 commits August 15, 2025 21:57
- Add @types/node to root workspace to fix TypeScript compilation
- Add tslib to @sshield/config package for TypeScript helpers
- Update tsconfig.json with project references from nx sync

These changes fix the build errors and enable successful compilation
of the @sshield/config package through nx.
- Fix package.json exports to point to correct TypeScript config paths
  (./ts/ instead of non-existent ./dist/typescript/)
- Update nx from 21.2.2 to 21.3.7 to align with other @nx packages
- Update @nx/workspace from 21.2.2 to 21.3.7 for consistency
- Update @typescript-eslint packages to v8 for ESLint 9 compatibility
  - @typescript-eslint/parser: ^7.18.0 -> ^8.38.0
  - @typescript-eslint/eslint-plugin: ^7.18.0 -> ^8.0.0 (peerDep)

These changes resolve peer dependency warnings and ensure proper
package exports for TypeScript configuration files.
- Add tsup export to @sshield/config index
- Add baseUrl to tsconfig.base.json to support path mappings
- Create package scaffolder script (tools/scripts/scaffold-package.mjs)
  - Scaffolds new packages with full @sshield/config integration
  - Supports packages and plugins directories
  - Includes TypeScript, ESLint, Prettier, Mocha configurations
  - Automatic Nx project discovery and build setup
- Add npm script: `pnpm scaffold <name>` for easy package creation
- Create comprehensive documentation for scaffolder usage

The scaffolder enables rapid package development with consistent
configurations across the monorepo.
- Remove .nx/workspace-data files from git (already in .gitignore)
- Update pnpm-lock.yaml after installing dependencies
…b.com:shaiknoorullah/sshield into feat-monorepo-init
Add full tooling support to @sshield/config and package scaffolder:

- Add pkg configuration for building cross-platform binaries
- Enhance tsup config with comprehensive bundling options (ESM/CJS, sourcemaps, tree-shaking)
- Update mocha config with detailed test runner settings
- Add NYC configuration for code coverage (90% threshold)
- Update scaffolder to generate packages with all tooling integrated
  - TSup for bundling (ESM + CJS dual output)
  - Mocha + Chai for testing with TypeScript support
  - NYC for code coverage reporting
  - pkg for binary compilation targeting multiple platforms
- Fix command execution to use pnpm --filter for proper workspace context
- Update @sshield/config package exports to expose all tool configurations
- Use JSON format for mocha/nyc configs for better compatibility

All scaffolded packages now have complete development tooling out of the box,
including building, bundling, testing, coverage, and binary compilation.
…port

- Add ts-mocha package to devDependencies for simpler TS test execution
- Update test and coverage commands to use ts-mocha instead of plain mocha
- Simplify .mocharc.json configuration by removing ts-node settings
- Fix missing scope variable in bundle/test/coverage command generation
- ts-mocha handles TypeScript transpilation natively without complex ts-node setup

This provides a cleaner testing setup for scaffolded packages with better
TypeScript support out of the box.
Add complete tooling infrastructure for SSHield monorepo with all configurations
centralized in @sshield/config and automated via the package scaffolder.

BREAKING CHANGE: Migrated from nyc to c8, pkg to @yao-pkg/pkg

## @sshield/config Updates

- Add c8 config (replaces nyc)
- Add release-it config with conventional changelog
- Add commitlint config for strict commit messages
- Add lefthook config for Git hooks
- Add knip config for finding unused code
- Add typedoc config for API documentation
- Add devtools config for React DevTools + Ink
- Add ink-testing-library helpers
- Update pkg config to use @yao-pkg/pkg with Node 20+ support

## Package Scaffolder Enhancements

- Add ink-testing-library, react, react-devtools-core
- Replace pkg with @yao-pkg/pkg
- Replace nyc with c8
- Add release-it, typedoc dependencies
- Add docs and release Nx targets
- Generate .c8rc.json, typedoc.json, .release-it.json configs

## Root-Level Tooling

- Add lefthook for Git hooks management
- Add commitlint for conventional commits
- Add knip for unused code detection
- Add docs and knip scripts
- Create .lefthook.yml, commitlint.config.mjs, knip.config.ts
- Add prepare script to install lefthook hooks

## TypeDoc Integration

- Create typedoc-to-fuma.ts bridge for Fuma-docs compatibility
- Auto-generates frontmatter and meta.json files

All configurations are centralized in @sshield/config and shared across packages.
…b.com:shaiknoorullah/sshield into feat-monorepo-init
…mit workflow

- Updated commitlint.config.mjs to dynamically generate scopes from directory structure
- Added 'maintenance' and 'init' commit types to match cz-git configuration
- Updated @sshield/config commitlint to include new types with prompt definitions
- Both tools now use identical type-enum and scope-enum for validation
- Commitizen provides interactive commit creation, commitlint enforces validation
…b.com:shaiknoorullah/sshield into feat-monorepo-init
- Added nfpm configuration for .deb, .rpm, and .apk packages
- Created PKGBUILD generators for Arch Linux AUR distribution
- Updated release-it config to support GitHub releases with binary assets
- Added maintenance and init types to changelog generation
- Created package-dist.mjs script for automated package generation
- Updated scaffolder to include package target in new projects
- Added comprehensive PACKAGING.md documentation

Supports distribution via:
- npm (Node.js package registry)
- GitHub Releases (binary downloads)
- apt (Debian/Ubuntu via .deb)
- dnf/yum (Fedora/RHEL via .rpm)
- apk (Alpine Linux)
- pacman/yay/paru (Arch Linux via AUR)
- Added .prettierrc.json with standard formatting rules
- Added eslint.config.mjs using config's own eslint configuration
- Added .prettierignore and .eslintignore to exclude build artifacts
- Updated package.json scripts with lint, format, and typecheck commands
- Added eslint, prettier, and typescript to devDependencies for self-linting

The config package now uses its own tooling configurations for consistency
…b.com:shaiknoorullah/sshield into feat-monorepo-init
The cz.config.mjs file is an ES module but was using __dirname without defining it.
Added fileURLToPath and dirname imports to properly define __dirname for ES modules.

Fixes: __dirname is not defined in ES module scope error when running pnpm commit
…b.com:shaiknoorullah/sshield into feat-monorepo-init
Added readDirSafe function to safely read directories, returning empty array
if directory doesn't exist. This prevents ENOENT errors when directories
like tests/, plugins/, etc. haven't been created yet.

Fixes: ENOENT: no such file or directory, scandir error when running pnpm commit
…b.com:shaiknoorullah/sshield into feat-monorepo-init
claude and others added 28 commits November 15, 2025 22:26
- Escaped dollar signs in template strings to prevent TypeScript from interpreting them as variables
- Added explicit type annotations to lambda functions to fix implicit any errors
- Prefixed unused pkgbuild parameter with underscore in generateSrcinfo function

Fixes all TypeScript errors in config/src/nfpm/nfpm.config.ts and config/src/aur/pkgbuild.config.ts
Root package.json:
- Added prettier, eslint, and TypeScript ESLint plugins to devDependencies
- These are required for lefthook pre-commit hooks to run properly

Root configuration files:
- Created .prettierrc.json with standard formatting rules
- Created eslint.config.mjs with TypeScript and Prettier integration
- Both configs ensure consistent code style across the monorepo

TypeScript configuration:
- Updated root tsconfig.json to exclude tools/scripts, dist, coverage, and docs
- Created tools/scripts/tsconfig.json with ES module support for script files
- Prevents import.meta errors in script files that use ESM features

Package scaffolder fixes:
- Removed unused getWorkspaceLayout import
- Prefixed unused _tree parameter with underscore
- Added explicit string[] type annotation for parsedTags array

Resolves all pre-commit hook failures and TypeScript compilation errors
…b.com:shaiknoorullah/sshield into feat-monorepo-init
Updated nx.json to use feat-monorepo-init as the default base branch instead of main.
This fixes the 'Failed to process project graph' error in pre-commit hooks when
running nx affected commands.

Fixes: NX affected criteria failing because main branch doesn't exist
…b.com:shaiknoorullah/sshield into feat-monorepo-init
Replaced the full eslint config with a minimal version that doesn't import
packages. This prevents NX from failing when those packages aren't installed yet.

After running pnpm install, the full config can be restored.
…b.com:shaiknoorullah/sshield into feat-monorepo-init
…igrate to ESM

- Create typed config structure: config/ts/{package,ui,plugin}/tsconfig.{json,lib.json,spec.json}
- Convert config package to full ESM with "type": "module" and explicit .js extensions
- Add package exports for all typed configs (@sshield/config/ts/*/*)
- Migrate example-cli to use centralized UI configs with minimal overrides
- Fix UI lib config to only include node types (React types only in spec config)

This change centralizes TypeScript configuration by package type (pure packages, UI packages with Ink/React, and plugins) and reduces configuration duplication across packages.
- Change from named import to default import
- Use compiled .js file from dist instead of .ts source
- Fixes knip error: "_eslintConfig.eslintConfig is not iterable"
…b.com:shaiknoorullah/sshield into feat-monorepo-init
- Add CLI entry point with Commander.js (src/cli.ts)
- Add hello command with Ink UI component (src/commands/hello.tsx)
- Add HelloWorld component with styled terminal UI (src/components/HelloWorld.tsx)
- Add logger utility with colored output (src/utils/logger.ts)
- Add comprehensive test suite with Mocha/Chai and Ink testing library
- Configure ts-mocha for running TypeScript tests with ESM support
- Update test configuration to run tests directly from source files

The example-cli now demonstrates the full SSHield monorepo tooling stack with TypeScript, Ink for terminal UIs, Commander.js for CLI parsing, and a complete testing setup. All 10 tests pass successfully.
…DfDmchkj4bPB8b4dH' of github.com:shaiknoorullah/sshield into feat-monorepo-init
- Configure c8 code coverage with realistic thresholds (65%+ coverage)
- Add pkg binary packaging support for 6 platforms (Linux/macOS/Windows x64/ARM64)
- Add nfpm configuration for creating .deb and .rpm system packages
- Create tsup bundling configuration for optimized builds
- Add wrapper script for system package installations
- Update project.json with bundle, pkg, and nfpm:* targets
- Add comprehensive PACKAGING.md documentation covering all distribution methods

Testing & Coverage:
- All tests pass with 68.55% coverage (100% on testable components)
- HTML, LCOV, and JSON coverage reports generated

Binary Packaging (pkg):
- Successfully creates binaries for 6 platforms
- Note: Ink-based CLIs have limitations with pkg due to ESM/React complexity
- Binaries range from 29MB to 54MB

System Packaging (nfpm):
- Debian (.deb) and RPM (.rpm) package configurations
- Includes post-install scripts for dependency installation
- Installs to /usr/lib with wrapper at /usr/bin/example-cli

Documentation includes best practices, known limitations, and recommended distribution approaches for production use.
…b.com:shaiknoorullah/sshield into feat-monorepo-init
- Add typecheck target to example-cli project.json using tsconfig.spec.json
- Add typecheck target to config project.json
- Update .lefthook.yml to use nx affected typecheck instead of raw tsc
- Update lint patterns in example-cli to include .tsx files

This ensures each package uses its own TypeScript configuration during typecheck, which is essential for packages with different module systems (ESM vs CommonJS) and JSX requirements.
- Add typecheck target to config/project.json
- This was missing from the previous commit and is needed for nx affected typecheck to work
…b.com:shaiknoorullah/sshield into feat-monorepo-init
**Fixes:**
- Remove invalid nfpm v2 fields from package-dist.mjs:
  - Remove 'bindir' field (doesn't exist in nfpm v2)
  - Remove 'dependencies' in overrides (use top-level 'depends' instead)
  - Simplify to use top-level scripts and format-specific sections

**Documentation Updates:**
- Add prominent warning that bundle/pkg targets don't work with Ink
- Clearly mark working vs broken targets at the top
- Update recommendations to prioritize npm distribution
- Add section explaining why pkg doesn't work (top-level await)
- Remove misleading pkg binary documentation
- Add Docker and npx alternatives

**Testing Results:**
✅ build, test, typecheck, coverage all work perfectly
✅ build:package now generates valid nfpm configs
❌ bundle/pkg remain broken (Ink limitation, documented)

This provides users with clear guidance on working distribution methods.
…DfDmchkj4bPB8b4dH' of github.com:shaiknoorullah/sshield into feat-monorepo-init
**Problem:**
- nfpm.yaml expected binary at ./dist/example-cli (doesn't exist)
- Generated nfpm config from package-dist.mjs is for binary distributions
- No packages were being created

**Solution:**
- Updated nfpm.yaml to copy entire ./dist/ directory tree
- Fixed wrapper script paths (/usr/lib/example-cli/src/cli.js)
- Added nfpm:apk target for Alpine Linux packages
- Updated nfpm targets to use manual nfpm.yaml instead of generated one
- Use type: tree to copy compiled JavaScript directory structure

**Structure:**
- Packages install to /usr/lib/example-cli/
- Wrapper script at /usr/bin/example-cli
- Post-install runs 'npm install --production'

**Testing:**
Run 'pnpm nx nfpm:deb' to create Debian package
Run 'pnpm nx nfpm:all' to create .deb, .rpm, and .apk packages
**Change:**
- Update tsup.config.ts to use ESM format instead of CJS
- Add shims for __dirname and __filename compatibility
- Add shebang banner for direct execution

**Rationale:**
- ESM supports top-level await (Ink/React requirement)
- CJS bundling was failing with: "Module format 'cjs' does not support top-level await"
- ESM bundles can be executed directly with Node.js 18+

**Limitations:**
- ESM bundles won't work with 'pkg' (pkg only supports CJS)
- This makes 'pkg' binary packaging completely unusable
- For distribution, use npm/npx or nfpm system packages instead

**To test:**
pnpm build:bundle - Should now succeed with ESM bundle
…DfDmchkj4bPB8b4dH' of github.com:shaiknoorullah/sshield into feat-monorepo-init
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants