Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions packages/targets/browser-safari/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { execFileSync, execSync } from 'node:child_process';
import { createSign } from 'node:crypto';
import { existsSync } from 'node:fs';
import { mkdir, writeFile } from 'node:fs/promises';
import { join, resolve } from 'node:path';
import { join, posix, resolve } from 'node:path';

interface Config {
bundleId: string; // e.g. "com.example.MyApp.Extension"
Expand Down Expand Up @@ -62,18 +62,30 @@ function safeFileStem(value: string): string {
}

function planPath(outDir: string, bundleId: string, version: string): string {
return join(outDir, `${safeFileStem(bundleId)}-${safeFileStem(version)}.safari-plan.json`);
return joinLike(outDir, `${safeFileStem(bundleId)}-${safeFileStem(version)}.safari-plan.json`);
}

function isWindowsPath(path: string): boolean {
return path.includes('\\') || /^[A-Za-z]:\//.test(path.replace(/\\/g, '/'));
}

function joinLike(base: string, ...parts: string[]): string {
return isWindowsPath(base) ? join(base, ...parts) : posix.join(base, ...parts);
}

function resolveLike(base: string, path: string): string {
return isWindowsPath(base) ? resolve(base, path) : posix.resolve(base, path);
}

function buildPlan(
ctx: { projectDir: string; outDir: string; version: string },
config: Config,
): SafariPackagePlan {
const projectDir = resolve(ctx.projectDir, config.projectDir ?? '.');
const projectDir = resolveLike(ctx.projectDir, config.projectDir ?? '.');
const scheme = config.scheme ?? 'App';
const archivePath = join(ctx.outDir, `${safeFileStem(config.bundleId)}-${safeFileStem(ctx.version)}.xcarchive`);
const xcodeProj = join(projectDir, `${scheme}.xcodeproj`);
const xcWorkspace = join(projectDir, `${scheme}.xcworkspace`);
const archivePath = joinLike(ctx.outDir, `${safeFileStem(config.bundleId)}-${safeFileStem(ctx.version)}.xcarchive`);
const xcodeProj = joinLike(projectDir, `${scheme}.xcodeproj`);
const xcWorkspace = joinLike(projectDir, `${scheme}.xcworkspace`);
const appName = config.bundleId.split('.').pop() ?? 'Extension';
const archiveArgs = [
existsSync(xcWorkspace) ? '-workspace' : '-project',
Expand All @@ -97,7 +109,7 @@ function buildPlan(
command: 'xcrun',
args: [
'safari-web-extension-converter',
join(projectDir, 'dist'),
joinLike(projectDir, 'dist'),
'--app-name',
appName,
'--bundle-identifier',
Expand Down
9 changes: 7 additions & 2 deletions packages/targets/pkg-jsr/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineTarget, exec, manualSetup } from '@profullstack/sh1pt-core';
import { join } from 'node:path';
import { join, posix } from 'node:path';

// JSR (jsr.io) - TS-native registry. Publishes source TS directly; the
// registry handles transpilation for Node/Deno/Bun consumers. Scoped packages
Expand All @@ -11,7 +11,12 @@ interface Config {
}

function packagePath(ctx: { projectDir: string }, config: Config): string {
return config.packageDir ? join(ctx.projectDir, config.packageDir) : ctx.projectDir;
if (!config.packageDir) return ctx.projectDir;
return isWindowsPath(ctx.projectDir) ? join(ctx.projectDir, config.packageDir) : posix.join(ctx.projectDir, config.packageDir);
}

function isWindowsPath(path: string): boolean {
return path.includes('\\') || /^[A-Za-z]:\//.test(path.replace(/\\/g, '/'));
}
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Comment thread
greptile-apps[bot] marked this conversation as resolved.

function packageId(config: Config, version: string): string {
Expand Down
18 changes: 14 additions & 4 deletions packages/targets/plugin-vscode/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineTarget, setupGuide, exec } from '@profullstack/sh1pt-core';
import { mkdir, writeFile } from 'node:fs/promises';
import { join } from 'node:path';
import { join, posix } from 'node:path';

interface Config {
publisher: string; // e.g. "mycompany"
Expand All @@ -10,11 +10,21 @@ interface Config {
}

function packageDir(ctx: { projectDir: string }, config: Config): string {
return config.packageDir ? join(ctx.projectDir, config.packageDir) : ctx.projectDir;
if (!config.packageDir) return ctx.projectDir;
return isWindowsPath(ctx.projectDir) ? join(ctx.projectDir, config.packageDir) : posix.join(ctx.projectDir, config.packageDir);
}

function packageArtifact(ctx: { outDir: string; version: string }, config: Config): string {
return join(ctx.outDir, `${config.extensionName}-${ctx.version}.vsix`);
const file = `${config.extensionName}-${ctx.version}.vsix`;
return isWindowsPath(ctx.outDir) ? join(ctx.outDir, file) : posix.join(ctx.outDir, file);
}

function isWindowsPath(path: string): boolean {
return path.includes('\\') || /^[A-Za-z]:\//.test(path.replace(/\\/g, '/'));
}

function joinLike(base: string, ...parts: string[]): string {
return isWindowsPath(base) ? join(base, ...parts) : posix.join(base, ...parts);
}

function packageArgs(ctx: { outDir: string }, config: Config): string[] {
Expand Down Expand Up @@ -42,7 +52,7 @@ export default defineTarget<Config>({

async build(ctx, config) {
if (ctx.dryRun) {
const planPath = join(ctx.outDir, 'vscode-package.json');
const planPath = joinLike(ctx.outDir, 'vscode-package.json');
ctx.log(`vsce: dry-run package plan for ${config.publisher}.${config.extensionName} v${ctx.version}`);
await mkdir(ctx.outDir, { recursive: true });
await writeFile(planPath, renderPackagePlan(ctx, config), 'utf-8');
Expand Down
4 changes: 2 additions & 2 deletions packages/targets/tv-roku/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineTarget, manualSetup } from '@profullstack/sh1pt-core';
import { access, mkdir, readdir, readFile, stat, writeFile } from 'node:fs/promises';
import { join, relative, resolve } from 'node:path';
import { join, relative, resolve, sep } from 'node:path';

// Roku apps run on BrightScript + SceneGraph. Unlike tvOS / Android TV /
// Fire TV, there is no supported React runtime on Roku OS — react-tv is
Expand Down Expand Up @@ -42,7 +42,7 @@ async function listFiles(root: string, dir = root): Promise<string[]> {
const files = await Promise.all(entries.map(async (entry) => {
const path = join(dir, entry.name);
if (entry.isDirectory()) return listFiles(root, path);
if (entry.isFile()) return [relative(root, path)];
if (entry.isFile()) return [relative(root, path).split(sep).join('/')];
return [];
}));
return files.flat().sort();
Expand Down
4 changes: 2 additions & 2 deletions packages/targets/web-static/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineTarget, manualSetup } from '@profullstack/sh1pt-core';
import { cp, mkdir, readdir, stat, writeFile } from 'node:fs/promises';
import { join, relative, resolve } from 'node:path';
import { join, relative, resolve, sep } from 'node:path';

interface Config {
dir: string; // built output directory
Expand All @@ -14,7 +14,7 @@ async function listFiles(root: string, dir = root): Promise<string[]> {
const files = await Promise.all(entries.map(async (entry) => {
const path = join(dir, entry.name);
if (entry.isDirectory()) return listFiles(root, path);
if (entry.isFile()) return [relative(root, path)];
if (entry.isFile()) return [relative(root, path).split(sep).join('/')];
return [];
}));
return files.flat().sort();
Expand Down