{"id":17381798,"url":"https://github.com/ThinkThinkAI/JSONScript","last_synced_at":"2025-02-27T10:30:31.498Z","repository":{"id":240439995,"uuid":"802640308","full_name":"ThinkThinkAI/JSONScript","owner":"ThinkThinkAI","description":"JSONScript Technical Details","archived":false,"fork":false,"pushed_at":"2024-08-23T18:59:47.000Z","size":6,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-08-23T20:39:40.115Z","etag":null,"topics":["documentation","json","json-api","scripting","scripting-language"],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ThinkThinkAI.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-18T21:14:11.000Z","updated_at":"2024-08-23T18:59:50.000Z","dependencies_parsed_at":"2024-05-23T06:31:39.318Z","dependency_job_id":"68f63941-6dca-4915-a621-858176dda224","html_url":"https://github.com/ThinkThinkAI/JSONScript","commit_stats":null,"previous_names":["cmdlineai/jsonscript","commandai/jsonscript","thinkthinkai/jsonscript"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThinkThinkAI%2FJSONScript","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThinkThinkAI%2FJSONScript/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThinkThinkAI%2FJSONScript/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThinkThinkAI%2FJSONScript/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ThinkThinkAI","download_url":"https://codeload.github.com/ThinkThinkAI/JSONScript/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219842821,"owners_count":16556564,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["documentation","json","json-api","scripting","scripting-language"],"created_at":"2024-10-16T07:01:47.120Z","updated_at":"2024-10-16T07:04:49.371Z","avatar_url":"https://github.com/ThinkThinkAI.png","language":null,"funding_links":[],"categories":["Others"],"sub_categories":[],"readme":"# JSONScript\n\n**Version:** 0.1 Beta\n\nJSONScript is a simple format for defining a sequence of steps to be executed by an application. Each step can include commands to be executed in the terminal, creation of files, and optional comments for documentation.\n\n## Structure\n\nThe JSONScript format is an array of objects. Each object represents a step in the process and can have the following fields:\n\n- `cmd`: A command to be executed in the terminal.\n- `file`: An object with two properties:\n  - `name`: The name of the file to be created, including a path if necessary (defaults to the same directory).\n  - `data`: The content to be written into the file.\n- `comment`: A description or explanation of the step.\n\nThe steps are executed in the order they appear in the array, from top to bottom.\n\n## Example\n\nHere is an example JSONScript file:\n\n```json\n[\n  {\n    \"comment\": \"Step 1: Install the required npm package 'axios' for downloading files.\",\n    \"cmd\": \"npm install axios\"\n  },\n  {\n    \"comment\": \"Step 2: Create a JavaScript file that will contain the code to download the file.\",\n    \"file\": {\n      \"name\": \"downloadFile.js\",\n      \"data\": \"// This script downloads a file from a given URL\\nconst axios = require('axios');\\nconst fs = require('fs');\\nconst url = 'https://example.com/file.txt';\\nconst path = 'downloaded_file.txt';\\naxios({\\n  method: 'get',\\n  url: url,\\n  responseType: 'stream'\\n}).then(function (response) {\\n  response.data.pipe(fs.createWriteStream(path));\\n  console.log('File downloaded successfully.');\\n}).catch(function (error) {\\n  console.log('Error downloading the file:', error);\\n});\"\n    }\n  },\n  {\n    \"comment\": \"Step 3: Execute the JavaScript file to download the file from the given URL.\",\n    \"cmd\": \"node downloadFile.js\"\n  },\n  {\n    \"comment\": \"Step 4: Create a README file with instructions.\",\n    \"file\": {\n      \"name\": \"README.md\",\n      \"data\": \"# Node.js File Downloader\\nThis application downloads a file from a specified URL using Node.js.\\n\\n## Setup\\n1. Install the required npm package:\\n```\\nnpm install axios\\n```\\n2. Run the script to download the file:\\n```\\nnode downloadFile.js\\n```\"\n    }\n  }\n]\n```\n## Using JSONScript\n\n\t1.\tCreate a JSON file (e.g., steps.json) containing your JSONScript configuration.\n\t2.\tCreate a Node.js script (e.g., processSteps.js) to process the JSONScript file.\n\n# Sample Node.js Script\n```\nconst fs = require('fs');\nconst { exec } = require('child_process');\n\nconst steps = require('./steps.json'); // Assuming the JSON is saved as steps.json\n\nsteps.forEach((step, index) =\u003e {\n  if (step.comment) {\n    console.log(`Step ${index + 1}: ${step.comment}`);\n  }\n  if (step.cmd) {\n    exec(step.cmd, (error, stdout, stderr) =\u003e {\n      if (error) {\n        console.error(`Error executing command: ${error.message}`);\n        return;\n      }\n      if (stderr) {\n        console.error(`Error output: ${stderr}`);\n        return;\n      }\n      console.log(`Output: ${stdout}`);\n    });\n  }\n  if (step.file) {\n    fs.writeFile(step.file.name, step.file.data, (err) =\u003e {\n      if (err) {\n        console.error(`Error creating file ${step.file.name}: ${err.message}`);\n        return;\n      }\n      console.log(`File ${step.file.name} created successfully.`);\n    });\n  }\n});\n```\n\n\t3.\tRun the script using Node.js:\n```\nnode processSteps.js\n```\n\nThis will execute the steps defined in your JSONScript file.\n\n# Contribution\n\nFeel free to contribute to the JSONScript format and its implementation. Fork the repository and submit a pull request with your improvements.\n\n# License\n\nThis project is licensed under the MIT License.\n\n```\nMIT License\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FThinkThinkAI%2FJSONScript","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FThinkThinkAI%2FJSONScript","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FThinkThinkAI%2FJSONScript/lists"}