nextdesk 0.1.0 ā 0.1.2
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/dist/commands/dev.js +1 -1
- package/dist/commands/init.js +38 -28
- package/dist/utils/nextjs.js +16 -7
- package/package.json +1 -1
- package/src/commands/dev.ts +1 -1
- package/src/commands/init.ts +40 -28
- package/src/utils/nextjs.ts +17 -7
package/dist/commands/dev.js
CHANGED
|
@@ -18,7 +18,7 @@ async function dev(options) {
|
|
|
18
18
|
process.exit(1);
|
|
19
19
|
}
|
|
20
20
|
const appName = (0, nextjs_1.getAppName)(cwd);
|
|
21
|
-
console.log(chalk_1.default.bold(`\nš
|
|
21
|
+
console.log(chalk_1.default.bold(`\nš NextDesk ā ${appName}\n`));
|
|
22
22
|
// Start Next.js dev server
|
|
23
23
|
const nextSpinner = (0, ora_1.default)('Starting Next.js dev server...').start();
|
|
24
24
|
const nextProcess = (0, execa_1.default)('npm', ['run', 'dev'], {
|
package/dist/commands/init.js
CHANGED
|
@@ -12,7 +12,7 @@ const path_1 = __importDefault(require("path"));
|
|
|
12
12
|
async function init(options) {
|
|
13
13
|
const cwd = process.cwd();
|
|
14
14
|
const appName = options.name || path_1.default.basename(cwd);
|
|
15
|
-
console.log(chalk_1.default.bold(`\nš Initializing
|
|
15
|
+
console.log(chalk_1.default.bold(`\nš Initializing NextDesk project: ${appName}\n`));
|
|
16
16
|
const spinner = (0, ora_1.default)('Setting up project...').start();
|
|
17
17
|
try {
|
|
18
18
|
// Check if Next.js project exists
|
|
@@ -27,19 +27,37 @@ async function init(options) {
|
|
|
27
27
|
stdio: 'inherit'
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
|
-
// Create .
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
// Create .nextdesk directory with runtime
|
|
31
|
+
const nextdeskDir = path_1.default.join(cwd, '.nextdesk');
|
|
32
|
+
const binDir = path_1.default.join(nextdeskDir, 'bin');
|
|
33
|
+
if (!fs_1.default.existsSync(binDir)) {
|
|
34
|
+
fs_1.default.mkdirSync(binDir, { recursive: true });
|
|
34
35
|
}
|
|
35
|
-
//
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
// Try to find and copy runtime binary - look from various common locations
|
|
37
|
+
const possiblePaths = [
|
|
38
|
+
path_1.default.join(cwd, '../mydesk-poc/target/release/mydesk-poc'),
|
|
39
|
+
path_1.default.join(process.env.HOME || '', 'Projects/Personal/mydesk-poc/target/release/mydesk-poc'),
|
|
40
|
+
'/home/yoni/Desktop/Projects/Personal/mydesk-poc/target/release/mydesk-poc',
|
|
41
|
+
];
|
|
42
|
+
// Also check if running from node_modules (npx)
|
|
43
|
+
if (process.env.npm_package_name?.startsWith('nextdesk')) {
|
|
44
|
+
possiblePaths.unshift(path_1.default.join(cwd, '../../mydesk-poc/target/release/mydesk-poc'));
|
|
41
45
|
}
|
|
42
|
-
|
|
46
|
+
let runtimeCopied = false;
|
|
47
|
+
for (const src of possiblePaths) {
|
|
48
|
+
if (fs_1.default.existsSync(src)) {
|
|
49
|
+
const dst = path_1.default.join(binDir, 'nextdesk-runtime');
|
|
50
|
+
fs_1.default.copyFileSync(src, dst);
|
|
51
|
+
fs_1.default.chmodSync(dst, 0o755);
|
|
52
|
+
spinner.succeed('Runtime binary copied');
|
|
53
|
+
runtimeCopied = true;
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (!runtimeCopied) {
|
|
58
|
+
spinner.warn('Runtime binary not found');
|
|
59
|
+
}
|
|
60
|
+
// Create nextdesk.config.js
|
|
43
61
|
const configContent = `export default {
|
|
44
62
|
name: "${appName}",
|
|
45
63
|
version: "1.0.0",
|
|
@@ -48,17 +66,9 @@ async function init(options) {
|
|
|
48
66
|
height: 640,
|
|
49
67
|
title: "${appName}",
|
|
50
68
|
},
|
|
51
|
-
permissions: [
|
|
52
|
-
"fs:read",
|
|
53
|
-
"fs:write",
|
|
54
|
-
"shell:open",
|
|
55
|
-
"clipboard:read",
|
|
56
|
-
"clipboard:write",
|
|
57
|
-
"notification:show",
|
|
58
|
-
],
|
|
59
69
|
}
|
|
60
70
|
`;
|
|
61
|
-
fs_1.default.writeFileSync(path_1.default.join(cwd, '
|
|
71
|
+
fs_1.default.writeFileSync(path_1.default.join(cwd, 'nextdesk.config.js'), configContent);
|
|
62
72
|
// Update package.json scripts
|
|
63
73
|
const packageJsonPath = path_1.default.join(cwd, 'package.json');
|
|
64
74
|
if (fs_1.default.existsSync(packageJsonPath)) {
|
|
@@ -66,19 +76,19 @@ async function init(options) {
|
|
|
66
76
|
if (!packageJson.scripts) {
|
|
67
77
|
packageJson.scripts = {};
|
|
68
78
|
}
|
|
69
|
-
if (!packageJson.scripts['
|
|
70
|
-
packageJson.scripts['
|
|
79
|
+
if (!packageJson.scripts['nextdesk:dev']) {
|
|
80
|
+
packageJson.scripts['nextdesk:dev'] = 'npx nextdesk dev';
|
|
71
81
|
}
|
|
72
|
-
if (!packageJson.scripts['
|
|
73
|
-
packageJson.scripts['
|
|
82
|
+
if (!packageJson.scripts['nextdesk:build']) {
|
|
83
|
+
packageJson.scripts['nextdesk:build'] = 'npx nextdesk build';
|
|
74
84
|
}
|
|
75
85
|
fs_1.default.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2) + '\n');
|
|
76
86
|
}
|
|
77
|
-
spinner.succeed('
|
|
87
|
+
spinner.succeed('NextDesk initialized!');
|
|
78
88
|
console.log(chalk_1.default.bold('\n⨠All set!\n'));
|
|
79
89
|
console.log(chalk_1.default.gray(' Run these commands:'));
|
|
80
|
-
console.log(chalk_1.default.cyan(' npm run
|
|
81
|
-
console.log(chalk_1.default.cyan(' npm run
|
|
90
|
+
console.log(chalk_1.default.cyan(' npm run nextdesk:dev # Start desktop app in dev mode'));
|
|
91
|
+
console.log(chalk_1.default.cyan(' npm run nextdesk:build # Build desktop app for production\n'));
|
|
82
92
|
}
|
|
83
93
|
catch (err) {
|
|
84
94
|
spinner.fail(`Initialization failed: ${err.message}`);
|
package/dist/utils/nextjs.js
CHANGED
|
@@ -50,13 +50,22 @@ function waitForServer(url, timeout = 60000) {
|
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
52
|
function getRuntimeBinary() {
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
const cwd = process.cwd();
|
|
54
|
+
// Priority 1: Check in project's .nextdesk/bin/ (after init)
|
|
55
|
+
const localBinary = path_1.default.join(cwd, '.nextdesk/bin/nextdesk-runtime');
|
|
56
|
+
if (fs_1.default.existsSync(localBinary))
|
|
57
|
+
return localBinary;
|
|
58
|
+
// Priority 2: Check in node_modules/.nextdesk/bin/
|
|
59
|
+
const nodeModulesBinary = path_1.default.join(cwd, 'node_modules/.nextdesk/bin/nextdesk-runtime');
|
|
60
|
+
if (fs_1.default.existsSync(nodeModulesBinary))
|
|
61
|
+
return nodeModulesBinary;
|
|
62
|
+
// Priority 3: Check parent's mydesk-poc (development)
|
|
63
|
+
const devBinary = path_1.default.join(cwd, '../mydesk-poc/target/release/mydesk-poc');
|
|
55
64
|
if (fs_1.default.existsSync(devBinary))
|
|
56
65
|
return devBinary;
|
|
57
|
-
//
|
|
58
|
-
const
|
|
59
|
-
if (fs_1.default.existsSync(
|
|
60
|
-
return
|
|
61
|
-
throw new Error('
|
|
66
|
+
// Priority 4: Check hardcoded path from home
|
|
67
|
+
const homeBinary = path_1.default.join(process.env.HOME || '', 'Projects/Personal/mydesk-poc/target/release/mydesk-poc');
|
|
68
|
+
if (fs_1.default.existsSync(homeBinary))
|
|
69
|
+
return homeBinary;
|
|
70
|
+
throw new Error('NextDesk runtime not found. Run `npx nextdesk init` to set it up.');
|
|
62
71
|
}
|
package/package.json
CHANGED
package/src/commands/dev.ts
CHANGED
|
@@ -19,7 +19,7 @@ export async function dev(options: DevOptions) {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
const appName = getAppName(cwd)
|
|
22
|
-
console.log(chalk.bold(`\nš
|
|
22
|
+
console.log(chalk.bold(`\nš NextDesk ā ${appName}\n`))
|
|
23
23
|
|
|
24
24
|
// Start Next.js dev server
|
|
25
25
|
const nextSpinner = ora('Starting Next.js dev server...').start()
|
package/src/commands/init.ts
CHANGED
|
@@ -12,7 +12,7 @@ export async function init(options: InitOptions) {
|
|
|
12
12
|
const cwd = process.cwd()
|
|
13
13
|
const appName = options.name || path.basename(cwd)
|
|
14
14
|
|
|
15
|
-
console.log(chalk.bold(`\nš Initializing
|
|
15
|
+
console.log(chalk.bold(`\nš Initializing NextDesk project: ${appName}\n`))
|
|
16
16
|
|
|
17
17
|
const spinner = ora('Setting up project...').start()
|
|
18
18
|
|
|
@@ -32,22 +32,42 @@ export async function init(options: InitOptions) {
|
|
|
32
32
|
})
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
// Create .
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
// Create .nextdesk directory with runtime
|
|
36
|
+
const nextdeskDir = path.join(cwd, '.nextdesk')
|
|
37
|
+
const binDir = path.join(nextdeskDir, 'bin')
|
|
38
|
+
if (!fs.existsSync(binDir)) {
|
|
39
|
+
fs.mkdirSync(binDir, { recursive: true })
|
|
39
40
|
}
|
|
40
41
|
|
|
41
|
-
//
|
|
42
|
-
const
|
|
43
|
-
|
|
42
|
+
// Try to find and copy runtime binary - look from various common locations
|
|
43
|
+
const possiblePaths = [
|
|
44
|
+
path.join(cwd, '../mydesk-poc/target/release/mydesk-poc'),
|
|
45
|
+
path.join(process.env.HOME || '', 'Projects/Personal/mydesk-poc/target/release/mydesk-poc'),
|
|
46
|
+
'/home/yoni/Desktop/Projects/Personal/mydesk-poc/target/release/mydesk-poc',
|
|
47
|
+
]
|
|
44
48
|
|
|
45
|
-
if (
|
|
46
|
-
|
|
47
|
-
|
|
49
|
+
// Also check if running from node_modules (npx)
|
|
50
|
+
if (process.env.npm_package_name?.startsWith('nextdesk')) {
|
|
51
|
+
possiblePaths.unshift(path.join(cwd, '../../mydesk-poc/target/release/mydesk-poc'))
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
let runtimeCopied = false
|
|
55
|
+
for (const src of possiblePaths) {
|
|
56
|
+
if (fs.existsSync(src)) {
|
|
57
|
+
const dst = path.join(binDir, 'nextdesk-runtime')
|
|
58
|
+
fs.copyFileSync(src, dst)
|
|
59
|
+
fs.chmodSync(dst, 0o755)
|
|
60
|
+
spinner.succeed('Runtime binary copied')
|
|
61
|
+
runtimeCopied = true
|
|
62
|
+
break
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (!runtimeCopied) {
|
|
67
|
+
spinner.warn('Runtime binary not found')
|
|
48
68
|
}
|
|
49
69
|
|
|
50
|
-
// Create
|
|
70
|
+
// Create nextdesk.config.js
|
|
51
71
|
const configContent = `export default {
|
|
52
72
|
name: "${appName}",
|
|
53
73
|
version: "1.0.0",
|
|
@@ -56,17 +76,9 @@ export async function init(options: InitOptions) {
|
|
|
56
76
|
height: 640,
|
|
57
77
|
title: "${appName}",
|
|
58
78
|
},
|
|
59
|
-
permissions: [
|
|
60
|
-
"fs:read",
|
|
61
|
-
"fs:write",
|
|
62
|
-
"shell:open",
|
|
63
|
-
"clipboard:read",
|
|
64
|
-
"clipboard:write",
|
|
65
|
-
"notification:show",
|
|
66
|
-
],
|
|
67
79
|
}
|
|
68
80
|
`
|
|
69
|
-
fs.writeFileSync(path.join(cwd, '
|
|
81
|
+
fs.writeFileSync(path.join(cwd, 'nextdesk.config.js'), configContent)
|
|
70
82
|
|
|
71
83
|
// Update package.json scripts
|
|
72
84
|
const packageJsonPath = path.join(cwd, 'package.json')
|
|
@@ -77,22 +89,22 @@ export async function init(options: InitOptions) {
|
|
|
77
89
|
packageJson.scripts = {}
|
|
78
90
|
}
|
|
79
91
|
|
|
80
|
-
if (!packageJson.scripts['
|
|
81
|
-
packageJson.scripts['
|
|
92
|
+
if (!packageJson.scripts['nextdesk:dev']) {
|
|
93
|
+
packageJson.scripts['nextdesk:dev'] = 'npx nextdesk dev'
|
|
82
94
|
}
|
|
83
|
-
if (!packageJson.scripts['
|
|
84
|
-
packageJson.scripts['
|
|
95
|
+
if (!packageJson.scripts['nextdesk:build']) {
|
|
96
|
+
packageJson.scripts['nextdesk:build'] = 'npx nextdesk build'
|
|
85
97
|
}
|
|
86
98
|
|
|
87
99
|
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2) + '\n')
|
|
88
100
|
}
|
|
89
101
|
|
|
90
|
-
spinner.succeed('
|
|
102
|
+
spinner.succeed('NextDesk initialized!')
|
|
91
103
|
|
|
92
104
|
console.log(chalk.bold('\n⨠All set!\n'))
|
|
93
105
|
console.log(chalk.gray(' Run these commands:'))
|
|
94
|
-
console.log(chalk.cyan(' npm run
|
|
95
|
-
console.log(chalk.cyan(' npm run
|
|
106
|
+
console.log(chalk.cyan(' npm run nextdesk:dev # Start desktop app in dev mode'))
|
|
107
|
+
console.log(chalk.cyan(' npm run nextdesk:build # Build desktop app for production\n'))
|
|
96
108
|
|
|
97
109
|
} catch (err: any) {
|
|
98
110
|
spinner.fail(`Initialization failed: ${err.message}`)
|
package/src/utils/nextjs.ts
CHANGED
|
@@ -48,13 +48,23 @@ export function waitForServer(url: string, timeout = 60000): Promise<void> {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
export function getRuntimeBinary(): string {
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
const cwd = process.cwd()
|
|
52
|
+
|
|
53
|
+
// Priority 1: Check in project's .nextdesk/bin/ (after init)
|
|
54
|
+
const localBinary = path.join(cwd, '.nextdesk/bin/nextdesk-runtime')
|
|
55
|
+
if (fs.existsSync(localBinary)) return localBinary
|
|
56
|
+
|
|
57
|
+
// Priority 2: Check in node_modules/.nextdesk/bin/
|
|
58
|
+
const nodeModulesBinary = path.join(cwd, 'node_modules/.nextdesk/bin/nextdesk-runtime')
|
|
59
|
+
if (fs.existsSync(nodeModulesBinary)) return nodeModulesBinary
|
|
60
|
+
|
|
61
|
+
// Priority 3: Check parent's mydesk-poc (development)
|
|
62
|
+
const devBinary = path.join(cwd, '../mydesk-poc/target/release/mydesk-poc')
|
|
53
63
|
if (fs.existsSync(devBinary)) return devBinary
|
|
64
|
+
|
|
65
|
+
// Priority 4: Check hardcoded path from home
|
|
66
|
+
const homeBinary = path.join(process.env.HOME || '', 'Projects/Personal/mydesk-poc/target/release/mydesk-poc')
|
|
67
|
+
if (fs.existsSync(homeBinary)) return homeBinary
|
|
54
68
|
|
|
55
|
-
|
|
56
|
-
const prodBinary = path.join(__dirname, '../bin/mydesk-runtime')
|
|
57
|
-
if (fs.existsSync(prodBinary)) return prodBinary
|
|
58
|
-
|
|
59
|
-
throw new Error('MyDesk runtime binary not found. Run `cargo build` first.')
|
|
69
|
+
throw new Error('NextDesk runtime not found. Run `npx nextdesk init` to set it up.')
|
|
60
70
|
}
|