Skip to content

Commit

Permalink
fix(create): use relative file pathes in deployment generator
Browse files Browse the repository at this point in the history
  • Loading branch information
daKmoR committed Jul 31, 2022
1 parent b0630b5 commit 93a3089
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
3 changes: 2 additions & 1 deletion packages/create/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rocket/create",
"version": "0.0.8",
"version": "0.0.10",
"publishConfig": {
"access": "public"
},
Expand Down Expand Up @@ -32,6 +32,7 @@
"types:copy": "copyfiles \"./types/**/*.d.ts\" dist-types/"
},
"files": [
"deployments",
"dist",
"dist-types",
"src"
Expand Down
14 changes: 8 additions & 6 deletions packages/create/src/deployment-generator.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
import { existsSync, readFileSync, writeFileSync } from 'fs';
import { mkdir } from 'fs/promises';
import { existsSync } from 'fs';
import { mkdir, readFile, writeFile } from 'fs/promises';
import path from 'path';
import { blue } from 'colorette';

const GITHUB_ACTION_FILE_PATH = '.github/workflows';
const GITHUB_DEPLOYMENT_FILE_NAME = 'github-build-and-deploy-rocket-action.yml';
const GITHUB_DEPLOYMENT_FILE_PATH = `./deployments/github-pages/${GITHUB_DEPLOYMENT_FILE_NAME}`;
const GITHUB_DEPLOYMENT_FILE_PATH = `../deployments/github-pages/${GITHUB_DEPLOYMENT_FILE_NAME}`;

export async function generateGithubActionsDeployment(newFolderPath) {
console.log(`${blue('>')} Generating deployment actions...`);

const githubActionsPath = path.join(newFolderPath, GITHUB_ACTION_FILE_PATH);
await createDeploymentsFolder(githubActionsPath);

const githubDeploymentFile = readFileSync(path.join('.', GITHUB_DEPLOYMENT_FILE_PATH));
const githubDeploymentFile = await readFile(
new URL(GITHUB_DEPLOYMENT_FILE_PATH, import.meta.url),
);

const githubDeploymentFileTarget = path.join(
'.',
process.cwd(),
newFolderPath,
GITHUB_ACTION_FILE_PATH,
GITHUB_DEPLOYMENT_FILE_NAME,
);
writeFileSync(githubDeploymentFileTarget, githubDeploymentFile);
await writeFile(githubDeploymentFileTarget, githubDeploymentFile);
}

async function createDeploymentsFolder(deploymentsPath) {
Expand Down
2 changes: 1 addition & 1 deletion packages/search/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rocket/search",
"version": "0.6.0-alpha.0",
"version": "0.6.0-alpha.1",
"publishConfig": {
"access": "public"
},
Expand Down

0 comments on commit 93a3089

Please sign in to comment.