Skip to content

Commit 4a02257

Browse files
Merge pull request #11 from restackio/create-npx
add npx
2 parents 6f5aaaa + a5e98a4 commit 4a02257

File tree

3 files changed

+2172
-22
lines changed

3 files changed

+2172
-22
lines changed
+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env node
2+
3+
const fs = require('fs');
4+
const path = require('path');
5+
const { execSync } = require('child_process');
6+
7+
const packageRoot = path.join(__dirname, '..');
8+
const currentDir = process.cwd();
9+
10+
function copyFiles() {
11+
const filesToCopy = ['src', 'scheduleWorkflow.ts', 'tsconfig.json'];
12+
filesToCopy.forEach(file => {
13+
fs.cpSync(path.join(packageRoot, file), path.join(currentDir, file), { recursive: true });
14+
});
15+
16+
// Copy package.json separately and modify it
17+
const packageJson = require(path.join(packageRoot, 'package.json'));
18+
delete packageJson.bin;
19+
delete packageJson.files;
20+
fs.writeFileSync(path.join(currentDir, 'package.json'), JSON.stringify(packageJson, null, 2));
21+
}
22+
23+
function installDependencies() {
24+
console.log('Installing dependencies...');
25+
execSync('npm install', { stdio: 'inherit', cwd: currentDir });
26+
}
27+
28+
function main() {
29+
console.log('Creating Restack get-started project...');
30+
copyFiles();
31+
installDependencies();
32+
console.log('Project created successfully!');
33+
console.log('To start the service, run: npm run service');
34+
console.log('To schedule a workflow, run: npm run schedule');
35+
}
36+
37+
main();

0 commit comments

Comments
 (0)