New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

codesandboxer

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

codesandboxer - npm Package Compare versions

Comparing version 0.6.1 to 0.7.0

dist/templates/index.js

23

CHANGELOG.md
# Changelog
## 0.7.0
- [patch] 4b2b662:
- Reorganise how templates are stored
This is a bunch of changes that should mostly only be relevant internally.
First is that there is a `/templates` directory instead of `constants.js` to
store templates in. This makes it easy to read a template an easy to see how to add a new template
Secondly, while `codesandboxer-fs` still has its own templates, it inherits templates from `codesandboxer`
meaning that a template can be added in one and flow down to the other.
This sets up for Vue sandboxes.
- [minor] 9db3c25:
- template is now passed to 'finaliseCSB' as part of the first object not the second object.
- [patch] 4b2b662:
- Add Vue template to upload vue sandboxes
In addition, codesandboxer will do its best to autodetect if it is
processing a vue, react, or react-typescript sandbox, and use the
preferred sandbox unless otherwise specified.
## 0.6.1

@@ -4,0 +27,0 @@ - [patch] d0c0cef:

33

dist/constants.js

@@ -6,35 +6,2 @@ 'use strict';

});
exports.getSandboxUrl = exports.codesandboxURLJSON = exports.codesandboxURL = exports.newpkgJSON = exports.baseFilesTS = exports.baseFiles = undefined;
var _keys = require('babel-runtime/core-js/object/keys');
var _keys2 = _interopRequireDefault(_keys);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var baseFiles = exports.baseFiles = {
'index.html': {
content: '<div id="root"></div>'
},
'index.js': {
content: '/**\n This CodeSandbox has been automatically generated using\n `codesandboxer`. If you\'re curious how that happened, you can\n check out our docs here: https://github.com/noviny/codesandboxer\n\n If you experience any struggles with this sandbox, please raise an issue\n on github. :)\n*/\nimport React from \'react\';\nimport ReactDOM from \'react-dom\';\nimport App from \'./example\';\n\nReactDOM.render(\n<App />,\ndocument.getElementById(\'root\')\n);'
}
};
var baseFilesTS = exports.baseFilesTS = {
'index.html': {
content: '<div id="root"></div>'
},
'index.tsx': {
content: '/**\n This CodeSandbox has been automatically generated using\n `codesandboxer`. If you\'re curious how that happened, you can\n check out our docs here: https://github.com/noviny/codesandboxer\n\n If you experience any struggles with this sandbox, please raise an issue\n on github. :)\n*/\nimport * as React from \'react\';\nimport * as ReactDOM from \'react-dom\';\nimport App from \'./example\';\n\nReactDOM.render(\n<App />,\ndocument.getElementById(\'root\')\n);'
}
};
var newpkgJSON = exports.newpkgJSON = function newpkgJSON(dependencies) {
var name = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'codesandboxer-example';
var main = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'index.js';
return '{\n "name": "' + name + '",\n "version": "0.0.0",\n "description": "A simple example deployed using react-codesandboxer",\n "main": "' + main + '",\n "dependencies": {\n ' + (0, _keys2.default)(dependencies).map(function (k) {
return '"' + k + '": "' + dependencies[k] + '"';
}).join(',\n ') + '\n }\n}';
};
var codesandboxURL = exports.codesandboxURL = 'https://codesandbox.io/api/v1/sandboxes/define?query=module=/example.js';

@@ -41,0 +8,0 @@ var codesandboxURLJSON = exports.codesandboxURLJSON = 'https://codesandbox.io/api/v1/sandboxes/define?json=1';

57

dist/fetchFiles/index.js

@@ -19,2 +19,6 @@ 'use strict';

var _set = require('babel-runtime/core-js/set');
var _set2 = _interopRequireDefault(_set);
var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator');

@@ -48,4 +52,6 @@

var _constants = require('../constants');
var _templates = require('../templates');
var _templates2 = _interopRequireDefault(_templates);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -62,5 +68,6 @@

_ref$extensions = _ref.extensions,
extensions = _ref$extensions === undefined ? [] : _ref$extensions;
extensions = _ref$extensions === undefined ? [] : _ref$extensions,
template = _ref.template;
var extension, baseFilesToUse, config, pkg, _ref3, file, deps, internalImports, files, final;
var extensionsSet, extension, baseFilesToUse, config, pkg, _ref3, file, deps, internalImports, files, final;

@@ -71,24 +78,34 @@ return _regenerator2.default.wrap(function _callee$(_context) {

case 0:
extensionsSet = new _set2.default(extensions);
extension = _pathBrowserify2.default.extname(examplePath) || '.js';
baseFilesToUse = _constants.baseFiles;
if (extension && !['.js', '.json'].includes(extension)) {
if (['.ts', '.tsx'].includes(extension)) {
extensions.push('.ts', '.tsx');
baseFilesToUse = _constants.baseFilesTS;
} else {
extensions.push(extension);
}
extensionsSet.add(extension);
if (['.ts', '.tsx'].includes(extension) || template === 'create-react-app-typescript') {
if (!template) template = 'create-react-app-typescript';
extensionsSet.add('.ts');
extensionsSet.add('.tsx');
}
config = { extensions: extensions };
_context.next = 6;
if (extension === '.vue' || template === 'vue-cli') {
if (!template) template = 'vue-cli';
extensionsSet.add('.vue');
}
baseFilesToUse = _templates2.default[template];
if (!baseFilesToUse) baseFilesToUse = _templates2.default['create-react-app'];
if (!template) template = 'create-react-app';
config = { extensions: extensions, template: template };
_context.next = 11;
return (0, _ensurePkgJSON2.default)(pkgJSON, importReplacements, gitInfo, config);
case 6:
case 11:
pkg = _context.sent;
_context.next = 9;
_context.next = 14;
return (0, _ensureExample2.default)(example, importReplacements, pkg, examplePath, gitInfo, config);
case 9:
case 14:
_ref3 = _context.sent;

@@ -103,3 +120,3 @@ file = _ref3.file;

}));
_context.next = 16;
_context.next = 21;
return (0, _fetchInternalDependencies2.default)(internalImports.map(function (m) {

@@ -109,7 +126,7 @@ return (0, _resolvePath2.default)(examplePath, m);

case 16:
case 21:
final = _context.sent;
return _context.abrupt('return', final);
return _context.abrupt('return', (0, _extends4.default)({}, final, { template: template }));
case 18:
case 23:
case 'end':

@@ -116,0 +133,0 @@ return _context.stop();

@@ -17,3 +17,5 @@ 'use strict';

var files = _ref.files,
deps = _ref.deps;
deps = _ref.deps,
_ref$template = _ref.template,
template = _ref$template === undefined ? 'create-react-app' : _ref$template;

@@ -25,4 +27,2 @@ if (!config) config = {};

name = _config.name,
_config$template = _config.template,
template = _config$template === undefined ? 'create-react-app' : _config$template,
main = _config.main;

@@ -34,7 +34,13 @@

ensureReact(dependencies);
if (template === 'create-react-app' || template === 'create-react-app-typesctipt') {
ensureReact(dependencies);
}
if (template === 'vue-cli') {
ensureVue(dependencies);
}
var finalFiles = (0, _extends3.default)({}, files, {
'package.json': {
content: (0, _constants.newpkgJSON)(dependencies, name, main)
content: (0, _packagejson2.default)(dependencies, name, main)
},

@@ -61,4 +67,6 @@ 'sandbox.config.json': {

var _constants = require('../constants');
var _packagejson = require('../templates/packagejson');
var _packagejson2 = _interopRequireDefault(_packagejson);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -75,2 +83,8 @@

}
};
var ensureVue = function ensureVue(deps) {
if (!deps.vue) {
deps.vue = 'latest';
}
};

@@ -82,2 +82,11 @@ 'use strict';

var _templates = require('./templates');
Object.defineProperty(exports, 'templates', {
enumerable: true,
get: function get() {
return _templates.templates;
}
});
var _fetchRelativeFile = require('./fetchRelativeFile');

@@ -84,0 +93,0 @@

{
"name": "codesandboxer",
"version": "0.6.1",
"version": "0.7.0",
"description": "Fetch files from a git repository and upload them to codesandbox",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -116,3 +116,3 @@ # CodeSandboxer

The FinaliseCSB function is used to generate a parameter hash of the file contents that can be sent to codesandbox using `sendFilesToCSB`
The FinaliseCSB function is used to generate a parameter hash of the file contents that can be sent to codesandbox using `sendFilesToCSB`. It takes in the result of `fetchFiles`, however is separate so you can intercept files and either examine or modify them before it is sent to codesandbox.

@@ -147,13 +147,2 @@ The config object is optional, and can have any of the following properties:

### template
This template string sets what codesandbox template to use. Currently we support:
- `create-react-app`
- `create-react-app-typescript`
We auto-detect which one we think we should use, so you should only need to provide this if you want to override our selected template.
Unsupported templates will still cause the bundled files to be sent to codesandbox under that template, but the bundling may fail.
### sendFilesToCSB()

@@ -160,0 +149,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc