Skip to content

Commit

Permalink
modularium add command improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
aexol committed Jul 26, 2024
1 parent 2143cfd commit 4a9d4e4
Show file tree
Hide file tree
Showing 15 changed files with 447 additions and 31 deletions.
Binary file modified .DS_Store
Binary file not shown.
4 changes: 2 additions & 2 deletions adapters/apollo-server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion adapters/apollo-server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aexol/axolotl-apollo-server",
"version": "0.3.9",
"version": "0.4.0",
"private": false,
"main": "./lib/index.js",
"author": "Aexol, Artur Czemiel",
Expand Down
2 changes: 1 addition & 1 deletion adapters/graphql-yoga/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aexol/axolotl-graphql-yoga",
"version": "0.3.9",
"version": "0.4.0",
"private": false,
"main": "./lib/index.js",
"author": "Aexol, Artur Czemiel",
Expand Down
2 changes: 1 addition & 1 deletion adapters/stucco/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aexol/axolotl-stucco",
"version": "0.3.9",
"version": "0.4.0",
"private": false,
"main": "./lib/index.js",
"author": "Aexol, Artur Czemiel",
Expand Down
2 changes: 1 addition & 1 deletion examples/beerpub-apollo-server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "beerpub-apollo-server",
"version": "0.3.9",
"version": "0.4.0",
"description": "Automatically generated by graphql-editor-cli",
"main": "lib/index.js",
"type": "module",
Expand Down
2 changes: 1 addition & 1 deletion examples/beerpub-yoga-federated/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "beerpub-yoga-federated",
"version": "0.4.9",
"version": "0.5.0",
"description": "Automatically generated by graphql-editor-cli",
"main": "lib/index.js",
"type": "module",
Expand Down
2 changes: 1 addition & 1 deletion examples/beerpub-yoga/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "beerpub-yoga",
"version": "0.4.9",
"version": "0.5.0",
"description": "Automatically generated by graphql-editor-cli",
"main": "lib/index.js",
"type": "module",
Expand Down
15 changes: 8 additions & 7 deletions modularium/cli/add/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ export const addModuleAction = async ({ moduleKey }: { moduleKey: string }) => {
}
};

const TEMP_REPO_NAME = 'repo1234';

const runCommands = async (source: string, destination: string) => {
try {
const system = checkSystem({ node: '16.20' });
Expand All @@ -58,19 +60,18 @@ const runCommands = async (source: string, destination: string) => {
},
]);
fs.mkdirSync(destination, { recursive: true });
runCommand(`cd ${destination}`);
const clone = runCommand(`git clone -n --depth=1 --filter=tree:0 ${BASE_REPOSITORY} repo`);
const clone = runCommand(`git clone -n --depth=1 --filter=tree:0 ${BASE_REPOSITORY} ${TEMP_REPO_NAME}`);
if (!clone) return { error: "can't clone repository" };

const checkout = runCommand(
`cd repo && git config core.sparseCheckout true && git sparse-checkout set ${source} && git checkout && git config core.sparseCheckout false`,
`cd ${TEMP_REPO_NAME} && git config core.sparseCheckout true && git sparse-checkout set ${source} && git checkout && git config core.sparseCheckout false`,
);
if (!checkout) return { error: "can't clone repository" };
if (!checkout) return { error: "can't checkout repository" };
let move;
if (system.platform === 'win32') {
move = runCommand(`cd .. && move repo/${source} ./ && del repo`);
} else move = runCommand(`cd .. && mv repo/${source} ./ && rm -rf repo`);
if (!move) return { error: "can't clone repository" };
move = runCommand(`cd .. && move ${TEMP_REPO_NAME}/${source} ${destination} && del ${TEMP_REPO_NAME}`);
} else move = runCommand(`cd .. && mv ${TEMP_REPO_NAME}/${source} ${destination} && rm -rf ${TEMP_REPO_NAME}`);
if (!move) return { error: "can't move repository" };
// deps should be installed from docs. Later one we can install deps here somehow
return { success: true };
} catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion modularium/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aexol/modularium",
"version": "0.3.9",
"version": "0.4.0",
"private": false,
"main": "./lib/index.js",
"author": "Aexol, Artur Czemiel",
Expand Down
2 changes: 1 addition & 1 deletion modularium/root/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aexol/modularium-playground",
"version": "0.3.9",
"version": "0.4.0",
"description": "Axolotl modularium",
"main": "lib/index.js",
"type": "module",
Expand Down
Loading

0 comments on commit 4a9d4e4

Please sign in to comment.