Skip to content

Commit

Permalink
add module command working
Browse files Browse the repository at this point in the history
  • Loading branch information
aexol committed Jul 26, 2024
1 parent 72fd926 commit d1c4303
Show file tree
Hide file tree
Showing 14 changed files with 586 additions and 7 deletions.
22 changes: 16 additions & 6 deletions modularium/cli/add/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,28 @@ const runCommands = async (source: string, destination: string) => {
schema: `${destination}/schema.graphql`,
},
]);
const modulesFolderPaths = destination.split('/');
const modulesFolder = modulesFolderPaths.slice(0, -1).join('/');
fs.mkdirSync(destination, { recursive: true });
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 ${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 checkout repository" };
let move;
if (system.platform === 'win32') {
move = runCommand(`move ${TEMP_REPO_NAME}/${source} ${destination} && del ${TEMP_REPO_NAME}`);
} else move = runCommand(`mv ${TEMP_REPO_NAME}/${source} ${destination} && rm -rf ${TEMP_REPO_NAME}`);
move = runCommand(
`cd ${TEMP_REPO_NAME} && git config core.sparseCheckout true && git sparse-checkout set ${source} && git checkout && git config core.sparseCheckout false && cd .. && move ${TEMP_REPO_NAME}/${source} ${modulesFolder} && del ${TEMP_REPO_NAME}`,
);
} else
move = runCommand(
`cd ${TEMP_REPO_NAME} && \
git config core.sparseCheckout true && \
git sparse-checkout set ${source} && \
git checkout && \
git config core.sparseCheckout false && \
cd .. && \
mv ${TEMP_REPO_NAME}/${source} ${modulesFolder} && \
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 };
Expand Down
7 changes: 7 additions & 0 deletions modularium/playground/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends":["../../.eslintrc.json"],
"rules": {
"@typescript-eslint/no-explicit-any":0
}
}

4 changes: 4 additions & 0 deletions modularium/playground/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.env
/lib
/node_modules
.graphql-editor-auth.json
8 changes: 8 additions & 0 deletions modularium/playground/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"arrowParens": "always",
"semi": true,
"trailingComma": "all",
"singleQuote": true,
"printWidth": 120,
"tabWidth": 2
}
4 changes: 4 additions & 0 deletions modularium/playground/axolotl.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"schema": "schema.graphql",
"models": "src/models.ts"
}
19 changes: 19 additions & 0 deletions modularium/playground/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "@aexol/modularium-playground",
"version": "0.4.1",
"description": "Axolotl modularium",
"main": "lib/index.js",
"type": "module",
"private": true,
"publishConfig": {
"access": "restricted"
},
"scripts": {
"start": "modularium add users"
},
"author": "GraphQL Editor Centaur Generator",
"license": "ISC",
"devDependencies": {
"@aexol/modularium": "^0.4.1"
}
}
8 changes: 8 additions & 0 deletions modularium/playground/src/axolotl.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Models } from '@/src/models.js';
import { Axolotl } from '@aexol/axolotl-core';
import { graphqlYogaAdapter } from '@aexol/axolotl-graphql-yoga';

export const { applyMiddleware, createResolvers, createDirectives, adapter } = Axolotl(graphqlYogaAdapter)<
Models,
unknown
>();
8 changes: 8 additions & 0 deletions modularium/playground/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { adapter } from '@/src/axolotl.js';
import resolvers from '@/src/resolvers.js';

// This is yoga specific

adapter({ resolvers }).server.listen(parseInt(process.env.PORT || '4000'), () => {
console.log('LISTENING to ' + process.env.PORT || '4000');
});
Loading

0 comments on commit d1c4303

Please sign in to comment.