ossplate 0.1.0

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.
Files changed (45) hide show
  1. package/README.md +7 -0
  2. package/bin/darwin-arm64/ossplate +0 -0
  3. package/bin/darwin-x64/ossplate +3 -0
  4. package/bin/linux-x64/ossplate +3 -0
  5. package/bin/ossplate.js +5 -0
  6. package/bin/win32-x64/ossplate.exe +3 -0
  7. package/dist/index.d.ts +10 -0
  8. package/dist/index.js +56 -0
  9. package/package.json +43 -0
  10. package/scaffold/.github/workflows/ci.yml +76 -0
  11. package/scaffold/.github/workflows/publish-npm.yml +45 -0
  12. package/scaffold/.github/workflows/publish.yml +97 -0
  13. package/scaffold/.gitignore +9 -0
  14. package/scaffold/CONTRIBUTING.md +30 -0
  15. package/scaffold/LICENSE +9 -0
  16. package/scaffold/README.md +73 -0
  17. package/scaffold/core-rs/Cargo.lock +338 -0
  18. package/scaffold/core-rs/Cargo.toml +28 -0
  19. package/scaffold/core-rs/src/main.rs +1609 -0
  20. package/scaffold/docs/README.md +21 -0
  21. package/scaffold/docs/customizing-the-template.md +144 -0
  22. package/scaffold/docs/phase-1-contract.md +52 -0
  23. package/scaffold/docs/testing.md +71 -0
  24. package/scaffold/docs/upgrade-plan.md +251 -0
  25. package/scaffold/ossplate.toml +15 -0
  26. package/scaffold/scripts/verify.sh +36 -0
  27. package/scaffold/wrapper-js/README.md +7 -0
  28. package/scaffold/wrapper-js/bin/darwin-arm64/ossplate +0 -0
  29. package/scaffold/wrapper-js/bin/darwin-x64/ossplate +3 -0
  30. package/scaffold/wrapper-js/bin/linux-x64/ossplate +3 -0
  31. package/scaffold/wrapper-js/bin/ossplate.js +5 -0
  32. package/scaffold/wrapper-js/bin/win32-x64/ossplate.exe +3 -0
  33. package/scaffold/wrapper-js/package-lock.json +51 -0
  34. package/scaffold/wrapper-js/package.json +43 -0
  35. package/scaffold/wrapper-js/src/index.ts +69 -0
  36. package/scaffold/wrapper-js/tsconfig.json +14 -0
  37. package/scaffold/wrapper-py/README.md +7 -0
  38. package/scaffold/wrapper-py/hatch_build.py +16 -0
  39. package/scaffold/wrapper-py/pyproject.toml +37 -0
  40. package/scaffold/wrapper-py/src/ossplate/__init__.py +3 -0
  41. package/scaffold/wrapper-py/src/ossplate/bin/darwin-arm64/ossplate +0 -0
  42. package/scaffold/wrapper-py/src/ossplate/bin/darwin-x64/ossplate +3 -0
  43. package/scaffold/wrapper-py/src/ossplate/bin/linux-x64/ossplate +3 -0
  44. package/scaffold/wrapper-py/src/ossplate/bin/win32-x64/ossplate.exe +3 -0
  45. package/scaffold/wrapper-py/src/ossplate/cli.py +55 -0
package/README.md ADDED
@@ -0,0 +1,7 @@
1
+ # JavaScript Wrapper For Ossplate
2
+
3
+ This package is the JavaScript wrapper surface for Ossplate.
4
+
5
+ It delegates to the canonical Rust binary instead of implementing its own CLI behavior.
6
+
7
+ Use `OSSPLATE_BINARY` during local development to point the wrapper at a specific binary.
Binary file
@@ -0,0 +1,3 @@
1
+ #!/bin/sh
2
+
3
+ printf '{"status":"packaged-stub"}\n'
@@ -0,0 +1,3 @@
1
+ #!/bin/sh
2
+
3
+ printf '{"status":"packaged-stub"}\n'
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { runOssplate } from "../dist/index.js";
4
+
5
+ runOssplate(process.argv.slice(2));
@@ -0,0 +1,3 @@
1
+ #!/bin/sh
2
+
3
+ printf '{"status":"packaged-stub"}\n'
@@ -0,0 +1,10 @@
1
+ export declare function resolveOssplateBinary(options?: {
2
+ baseDir?: string;
3
+ platform?: NodeJS.Platform;
4
+ arch?: string;
5
+ }): string;
6
+ export declare function runOssplate(args?: string[], options?: {
7
+ baseDir?: string;
8
+ platform?: NodeJS.Platform;
9
+ arch?: string;
10
+ }): void;
package/dist/index.js ADDED
@@ -0,0 +1,56 @@
1
+ import { accessSync, constants } from "node:fs";
2
+ import { spawn } from "node:child_process";
3
+ import { fileURLToPath } from "node:url";
4
+ import { dirname, join } from "node:path";
5
+ import { arch as runtimeArch, platform as runtimePlatform } from "node:os";
6
+ const __dirname = dirname(fileURLToPath(import.meta.url));
7
+ const ENV_OVERRIDE = "OSSPLATE_BINARY";
8
+ const TEMPLATE_ROOT_ENV = "OSSPLATE_TEMPLATE_ROOT";
9
+ const TARGETS = {
10
+ darwin: { arm64: "darwin-arm64", x64: "darwin-x64" },
11
+ linux: { x64: "linux-x64" },
12
+ win32: { x64: "win32-x64" }
13
+ };
14
+ export function resolveOssplateBinary(options = {}) {
15
+ const envOverride = process.env[ENV_OVERRIDE];
16
+ if (envOverride) {
17
+ return envOverride;
18
+ }
19
+ const platform = options.platform ?? runtimePlatform();
20
+ const arch = options.arch ?? runtimeArch();
21
+ const target = TARGETS[platform]?.[arch];
22
+ if (!target) {
23
+ throw new Error(`Unsupported platform/arch: ${platform}/${arch}`);
24
+ }
25
+ const executable = platform === "win32" ? "ossplate.exe" : "ossplate";
26
+ const baseDir = options.baseDir ?? join(__dirname, "..");
27
+ const packagedPath = join(baseDir, "bin", target, executable);
28
+ assertExecutable(packagedPath);
29
+ return packagedPath;
30
+ }
31
+ export function runOssplate(args = [], options = {}) {
32
+ const binPath = resolveOssplateBinary(options);
33
+ const baseDir = options.baseDir ?? join(__dirname, "..");
34
+ const child = spawn(binPath, args, {
35
+ stdio: "inherit",
36
+ env: {
37
+ ...process.env,
38
+ [TEMPLATE_ROOT_ENV]: process.env[TEMPLATE_ROOT_ENV] ?? join(baseDir, "scaffold")
39
+ }
40
+ });
41
+ child.on("exit", (code) => {
42
+ process.exit(code ?? 0);
43
+ });
44
+ child.on("error", (error) => {
45
+ console.error(`ossplate: ${error.message}`);
46
+ process.exit(1);
47
+ });
48
+ }
49
+ function assertExecutable(filePath) {
50
+ try {
51
+ accessSync(filePath, constants.X_OK);
52
+ }
53
+ catch {
54
+ throw new Error(`Bundled ossplate binary not found or not executable at ${filePath}`);
55
+ }
56
+ }
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "author": "Stef <stefdevscore@github.com>",
3
+ "bin": {
4
+ "ossplate": "bin/ossplate.js"
5
+ },
6
+ "description": "A practical baseline for shipping one project across Cargo, npm, and PyPI without starting from scratch every time.",
7
+ "devDependencies": {
8
+ "@types/node": "^24.6.0",
9
+ "typescript": "^5.9.3"
10
+ },
11
+ "files": [
12
+ "bin",
13
+ "dist",
14
+ "README.md",
15
+ "scaffold",
16
+ "scaffold/.gitignore"
17
+ ],
18
+ "keywords": [
19
+ "oss",
20
+ "ossplate",
21
+ "cli"
22
+ ],
23
+ "license": "Unlicense",
24
+ "main": "./dist/index.js",
25
+ "name": "ossplate",
26
+ "publishConfig": {
27
+ "access": "public"
28
+ },
29
+ "repository": {
30
+ "directory": "wrapper-js",
31
+ "type": "git",
32
+ "url": "https://github.com/stefdevscore/ossplate"
33
+ },
34
+ "scripts": {
35
+ "build": "tsc -p tsconfig.json",
36
+ "pack:check": "npm pack --dry-run",
37
+ "prepack": "node ../scripts/stage-distribution-assets.mjs",
38
+ "stage:dist": "node ../scripts/stage-distribution-assets.mjs",
39
+ "test": "npm run build && node --test test/cli.test.js"
40
+ },
41
+ "type": "module",
42
+ "version": "0.1.0"
43
+ }
@@ -0,0 +1,76 @@
1
+ # ossplate:workflow-name:start
2
+ name: Ossplate CI
3
+ # ossplate:workflow-name:end
4
+
5
+ on:
6
+ push:
7
+ branches:
8
+ - main
9
+ pull_request:
10
+
11
+ jobs:
12
+ template-readiness:
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+ - uses: dtolnay/rust-toolchain@stable
17
+ - uses: actions/setup-node@v4
18
+ with:
19
+ node-version: '20'
20
+ - run: cargo run --quiet --manifest-path core-rs/Cargo.toml -- validate
21
+ - run: cargo run --quiet --manifest-path core-rs/Cargo.toml -- sync --check
22
+ - run: node --test ./scripts/validate-template-readiness.test.mjs
23
+
24
+ rust:
25
+ needs: template-readiness
26
+ runs-on: ubuntu-latest
27
+ steps:
28
+ - uses: actions/checkout@v4
29
+ - uses: dtolnay/rust-toolchain@stable
30
+ - run: cargo fmt --check
31
+ working-directory: ./core-rs
32
+ - run: cargo clippy -- -D warnings
33
+ working-directory: ./core-rs
34
+ - run: cargo test
35
+ working-directory: ./core-rs
36
+
37
+ js:
38
+ needs: template-readiness
39
+ runs-on: ubuntu-latest
40
+ steps:
41
+ - uses: actions/checkout@v4
42
+ - uses: dtolnay/rust-toolchain@stable
43
+ - uses: actions/setup-node@v4
44
+ with:
45
+ node-version: '20'
46
+ cache: npm
47
+ cache-dependency-path: ./wrapper-js/package-lock.json
48
+ - run: npm ci
49
+ working-directory: ./wrapper-js
50
+ - run: npm run build
51
+ working-directory: ./wrapper-js
52
+ - run: npm test
53
+ working-directory: ./wrapper-js
54
+ - run: npm pack --dry-run
55
+ working-directory: ./wrapper-js
56
+
57
+ python:
58
+ needs: template-readiness
59
+ runs-on: ubuntu-latest
60
+ steps:
61
+ - uses: actions/checkout@v4
62
+ - uses: dtolnay/rust-toolchain@stable
63
+ - uses: actions/setup-node@v4
64
+ with:
65
+ node-version: '20'
66
+ - uses: actions/setup-python@v5
67
+ with:
68
+ python-version: '3.11'
69
+ - name: Test and build
70
+ run: |
71
+ python -m pip install --upgrade pip
72
+ pip install -e .
73
+ pip install build
74
+ python -m unittest discover -s tests -p 'test_*.py'
75
+ python -m build --wheel
76
+ working-directory: ./wrapper-py
@@ -0,0 +1,45 @@
1
+ # ossplate:workflow-name:start
2
+ name: Ossplate publish-npm
3
+ # ossplate:workflow-name:end
4
+
5
+ on:
6
+ release:
7
+ types: [published]
8
+ workflow_dispatch:
9
+
10
+ jobs:
11
+ publish-npm:
12
+ runs-on: ubuntu-latest
13
+ permissions:
14
+ contents: read
15
+ id-token: write
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+ - uses: actions/setup-node@v4
19
+ with:
20
+ node-version: '20'
21
+ registry-url: 'https://registry.npmjs.org'
22
+ cache: npm
23
+ cache-dependency-path: ./wrapper-js/package-lock.json
24
+ - name: Detect published version
25
+ id: published
26
+ working-directory: ./wrapper-js
27
+ run: |
28
+ NAME=$(node -p "require('./package.json').name")
29
+ VERSION=$(node -p "require('./package.json').version")
30
+ echo "name=$NAME" >> "$GITHUB_OUTPUT"
31
+ echo "version=$VERSION" >> "$GITHUB_OUTPUT"
32
+ if npm view "$NAME@$VERSION" version >/dev/null 2>&1; then
33
+ echo "already=true" >> "$GITHUB_OUTPUT"
34
+ echo "::notice title=npm::${NAME}@${VERSION} is already published; skipping."
35
+ else
36
+ echo "already=false" >> "$GITHUB_OUTPUT"
37
+ fi
38
+ - if: steps.published.outputs.already != 'true'
39
+ run: npm ci
40
+ working-directory: ./wrapper-js
41
+ - if: steps.published.outputs.already != 'true'
42
+ run: npm publish --access public
43
+ working-directory: ./wrapper-js
44
+ env:
45
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
@@ -0,0 +1,97 @@
1
+ # ossplate:workflow-name:start
2
+ name: Ossplate publishing
3
+ # ossplate:workflow-name:end
4
+
5
+ on:
6
+ release:
7
+ types: [published]
8
+ workflow_dispatch:
9
+
10
+ jobs:
11
+ publish-pypi:
12
+ runs-on: ubuntu-latest
13
+ permissions:
14
+ contents: read
15
+ id-token: write
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+ - uses: actions/setup-python@v5
19
+ with:
20
+ python-version: '3.11'
21
+ - name: Build wheel
22
+ run: |
23
+ python -m pip install --upgrade pip
24
+ pip install build
25
+ python -m build --wheel
26
+ working-directory: ./wrapper-py
27
+ - name: Publish to PyPI
28
+ uses: pypa/gh-action-pypi-publish@release/v1
29
+ with:
30
+ packages-dir: ./wrapper-py/dist/
31
+ skip-existing: true
32
+
33
+ publish-cargo:
34
+ runs-on: ubuntu-latest
35
+ permissions:
36
+ contents: read
37
+ id-token: write
38
+ steps:
39
+ - uses: actions/checkout@v4
40
+ - uses: dtolnay/rust-toolchain@stable
41
+ - name: Authenticate with crates.io via OIDC
42
+ id: auth
43
+ continue-on-error: true
44
+ uses: rust-lang/crates-io-auth-action@v1
45
+ - name: Detect published crate version
46
+ id: version
47
+ working-directory: ./core-rs
48
+ run: |
49
+ CRATE_NAME=$(python3 - <<'PY'
50
+ import tomllib
51
+ with open("Cargo.toml", "rb") as f:
52
+ data = tomllib.load(f)
53
+ print(data["package"]["name"])
54
+ PY
55
+ )
56
+ CRATE_VERSION=$(python3 - <<'PY'
57
+ import tomllib
58
+ with open("Cargo.toml", "rb") as f:
59
+ data = tomllib.load(f)
60
+ print(data["package"]["version"])
61
+ PY
62
+ )
63
+ echo "name=$CRATE_NAME" >> "$GITHUB_OUTPUT"
64
+ echo "version=$CRATE_VERSION" >> "$GITHUB_OUTPUT"
65
+ if curl -fsSL "https://crates.io/api/v1/crates/${CRATE_NAME}/${CRATE_VERSION}" >/dev/null 2>&1; then
66
+ echo "already=true" >> "$GITHUB_OUTPUT"
67
+ echo "::notice title=cargo::${CRATE_NAME} ${CRATE_VERSION} is already published; skipping."
68
+ else
69
+ echo "already=false" >> "$GITHUB_OUTPUT"
70
+ fi
71
+ - name: Publish to crates.io
72
+ if: steps.version.outputs.already != 'true'
73
+ working-directory: ./core-rs
74
+ env:
75
+ CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token || secrets.CARGO_TOKEN }}
76
+ run: |
77
+ if [ -n "${{ steps.auth.outputs.token }}" ]; then
78
+ echo "::notice title=cargo::using crates.io OIDC token from trusted publishing."
79
+ else
80
+ echo "::notice title=cargo::OIDC token unavailable; falling back to CARGO_TOKEN secret."
81
+ fi
82
+ set +e
83
+ cargo publish 2>&1 | tee cargo-publish.log
84
+ status=${PIPESTATUS[0]}
85
+ set -e
86
+ if [ "$status" -eq 0 ]; then
87
+ exit 0
88
+ fi
89
+ if grep -q "status 429 Too Many Requests" cargo-publish.log; then
90
+ echo "::warning title=cargo::crates.io rate limit hit. Treating this publish attempt as non-blocking."
91
+ exit 0
92
+ fi
93
+ if grep -qi "already exists on crates.io index" cargo-publish.log; then
94
+ echo "::notice title=cargo::crate version already exists; skipping."
95
+ exit 0
96
+ fi
97
+ exit "$status"
@@ -0,0 +1,9 @@
1
+ .DS_Store
2
+ .venv/
3
+ __pycache__/
4
+ *.pyc
5
+ .tmp-*/
6
+ dist/
7
+ build/
8
+ node_modules/
9
+ target/
@@ -0,0 +1,30 @@
1
+ # Contributing
2
+
3
+ Use the root verification flow before committing changes:
4
+
5
+ ```bash
6
+ ./scripts/verify.sh
7
+ ```
8
+
9
+ That script mirrors the local release-confidence gate:
10
+
11
+ - Rust format, clippy, and tests
12
+ - `ossplate validate` and `ossplate sync --check`
13
+ - JavaScript wrapper tests and package dry-run
14
+ - Python wrapper tests
15
+
16
+ Useful operator commands:
17
+
18
+ ```bash
19
+ cargo run --manifest-path core-rs/Cargo.toml -- validate
20
+ cargo run --manifest-path core-rs/Cargo.toml -- sync --check
21
+ cargo run --manifest-path core-rs/Cargo.toml -- sync
22
+ ```
23
+
24
+ Current ownership model:
25
+
26
+ - `ossplate.toml` is the canonical identity source
27
+ - `sync` owns Rust/npm/Python metadata surfaces
28
+ - `sync` owns the root `README.md` identity block between `ossplate:readme-identity` markers
29
+ - `sync` owns the top-level workflow display names between `ossplate:workflow-name` markers
30
+ - workflow logic, auth, triggers, and job structure remain manual
@@ -0,0 +1,9 @@
1
+ This is free and unencumbered software released into the public domain.
2
+
3
+ Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.
4
+
5
+ In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.
6
+
7
+ 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 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.
8
+
9
+ For more information, please refer to <http://unlicense.org/>
@@ -0,0 +1,73 @@
1
+ <!-- ossplate:readme-identity:start -->
2
+ # Ossplate
3
+
4
+ A practical baseline for shipping one project across Cargo, npm, and PyPI without starting from scratch every time.
5
+ <!-- ossplate:readme-identity:end -->
6
+
7
+ ## What This Tool Gives You
8
+
9
+ - a canonical Rust CLI in [`core-rs/`](./core-rs)
10
+ - a thin npm wrapper in [`wrapper-js/`](./wrapper-js)
11
+ - a thin Python wrapper in [`wrapper-py/`](./wrapper-py)
12
+ - normal `push` / `pull_request` CI
13
+ - rerun-safe publish workflows for npm, PyPI, and Cargo
14
+ - setup and upgrade docs in [`docs/`](./docs/README.md)
15
+
16
+ ## Philosophy
17
+
18
+ This project is intentionally small.
19
+
20
+ It exists to validate and synchronize the shared identity of a multi-registry OSS scaffold before broader scaffolding features are added.
21
+
22
+ ## Core Commands
23
+
24
+ ```bash
25
+ cargo run --manifest-path core-rs/Cargo.toml -- validate
26
+ cargo run --manifest-path core-rs/Cargo.toml -- sync --check
27
+ cargo run --manifest-path core-rs/Cargo.toml -- create ../my-new-project
28
+ cargo run --manifest-path core-rs/Cargo.toml -- init --path ../existing-project
29
+ ```
30
+
31
+ Wrapper installs expose the same command surface as `ossplate`.
32
+
33
+ `create` and `init` now work from packaged wrapper artifacts as well as a source checkout. Installed wrappers carry a curated scaffold payload rather than a broad repo snapshot. Use flags to set the project identity during scaffold creation instead of editing `ossplate.toml` by hand first:
34
+
35
+ ```bash
36
+ cargo run --manifest-path core-rs/Cargo.toml -- create ../my-new-project \
37
+ --name "My Project" \
38
+ --repository "https://github.com/acme/my-project" \
39
+ --author-name "Acme" \
40
+ --author-email "oss@acme.dev" \
41
+ --rust-crate "my-project" \
42
+ --npm-package "@acme/my-project" \
43
+ --python-package "my-project-py" \
44
+ --command "my-project"
45
+ ```
46
+
47
+ ## Local Verify
48
+
49
+ Run the full local verification flow with:
50
+
51
+ ```bash
52
+ ./scripts/verify.sh
53
+ ```
54
+
55
+ This is the recommended local mirror of the CI gate.
56
+
57
+ ## Verification
58
+
59
+ - local workflow and layered testing guidance live in [docs/testing.md](./docs/testing.md)
60
+ - contributor workflow lives in [CONTRIBUTING.md](./CONTRIBUTING.md)
61
+ - `ossplate validate` reports owned metadata drift
62
+ - `ossplate sync --check` fails if owned metadata would be rewritten
63
+ - JS and Python artifact tests prove installed distributions can run `version`, `create`, and `validate`
64
+
65
+ ## Release Auth
66
+
67
+ - PyPI publishes from [`.github/workflows/publish.yml`](./.github/workflows/publish.yml) via GitHub OIDC trusted publishing
68
+ - Cargo publishes from [`.github/workflows/publish.yml`](./.github/workflows/publish.yml) via OIDC trusted publishing with `secrets.CARGO_TOKEN` as fallback
69
+ - npm publishes from [`.github/workflows/publish-npm.yml`](./.github/workflows/publish-npm.yml) with `secrets.NPM_TOKEN`
70
+
71
+ ## License
72
+
73
+ Licensed under the [Unlicense](LICENSE).