Socket
Socket
Sign inDemoInstall

@machinat/create-app

Package Overview
Dependencies
Maintainers
2
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@machinat/create-app - npm Package Compare versions

Comparing version 0.5.1 to 0.6.0-canary.0

lib/template/webview/pages/_document.tsx.t.d.ts

13

lib/cli.js

@@ -18,2 +18,3 @@ #!/usr/bin/env node

-r, --recognizer the intent recognition provider; regex or dialogflow (default: regex)
--npmTag the npm tag to install the packages with (default: latest)

@@ -39,2 +40,5 @@ Example

},
npmTag: {
type: 'string',
},
},

@@ -48,4 +52,9 @@ });

const projectPath = (0, path_1.resolve)(projectInput);
const { recognizer, platform: platforms } = cli.flags;
(0, createApp_1.default)({ platforms, projectPath, recognizer }).then((code) => process.exit(code));
const { recognizer, npmTag, platform: platforms } = cli.flags;
(0, createApp_1.default)({
platforms,
projectPath,
recognizer,
npmTag,
}).then((code) => process.exit(code));
//# sourceMappingURL=cli.js.map

3

lib/createApp.d.ts

@@ -5,4 +5,5 @@ declare type CreateAppOptions = {

recognizer: string;
npmTag?: string;
};
declare const createMachinatApp: ({ platforms, projectPath, recognizer, }: CreateAppOptions) => Promise<number>;
declare const createMachinatApp: ({ platforms, projectPath, recognizer, npmTag, }: CreateAppOptions) => Promise<number>;
export default createMachinatApp;

@@ -25,2 +25,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
/* eslint-disable no-console */
const path_1 = require("path");

@@ -35,30 +36,10 @@ const fs_1 = require("fs");

const formatCode = (code, parser) => (0, prettier_1.format)(code, { parser, singleQuote: true });
const getMachinatDependencies = (platforms, recognizer) => {
const dependencies = [
'@machinat/core',
'@machinat/http',
'@machinat/dev-tools',
'@machinat/redis-state',
'@machinat/stream',
'@machinat/script',
];
if (platforms.includes('webview')) {
dependencies.push('@machinat/webview');
const makeSureOfDir = async (file) => {
const targetDir = (0, path_1.dirname)(file);
if (!(0, fs_1.existsSync)(targetDir)) {
await thenifiedly_1.default.call(fs_1.mkdir, targetDir, { recursive: true });
}
if (platforms.includes('messenger')) {
dependencies.push('@machinat/messenger');
}
if (platforms.includes('telegram')) {
dependencies.push('@machinat/telegram');
}
if (platforms.includes('line')) {
dependencies.push('@machinat/line');
}
if (recognizer === 'dialogflow') {
dependencies.push('@machinat/dialogflow');
}
return dependencies.map((depName) => `${depName}@latest`);
};
const supportedPlatforms = ['messenger', 'telegram', 'line', 'webview'];
const createMachinatApp = async ({ platforms, projectPath, recognizer, }) => {
const createMachinatApp = async ({ platforms, projectPath, recognizer, npmTag = 'latest', }) => {
console.log(`Create a ${chalk_1.default.yellow('Machinat')} app in ${chalk_1.default.green(projectPath)}...\n`);

@@ -86,14 +67,17 @@ const projectName = (0, path_1.basename)(projectPath);

}
const templateFiles = await thenifiedly_1.default.call(glob_1.default, `${__dirname}/template/**/*.t.+(ts|js)`, { dot: true });
const templateFiles = await thenifiedly_1.default.call(glob_1.default, `${__dirname}/template/**/*`, { nodir: true });
const renderableExt = /\.t\.[t|j]s$/;
// write file content
await Promise.all(templateFiles.map(async (file) => {
const targetPath = (0, path_1.join)(projectPath, (0, path_1.relative)((0, path_1.join)(__dirname, 'template'), file).replace(/\.t\.[t|j]s$/, ''));
const targetPath = (0, path_1.join)(projectPath, (0, path_1.relative)((0, path_1.join)(__dirname, 'template'), file).replace(renderableExt, ''));
if (!file.match(renderableExt)) {
await makeSureOfDir(targetPath);
await thenifiedly_1.default.call(fs_1.copyFile, file, targetPath);
return;
}
const { default: buildContent, mode, name } = await Promise.resolve().then(() => __importStar(require(file)));
const content = (0, utils_1.polishFileContent)(buildContent(context));
if (content) {
const targetDir = (0, path_1.dirname)(targetPath);
if (!(0, fs_1.existsSync)(targetDir)) {
await thenifiedly_1.default.call(fs_1.mkdir, targetDir, { recursive: true });
}
const ext = (0, path_1.extname)(targetPath);
await makeSureOfDir(targetPath);
await thenifiedly_1.default.call(fs_1.writeFile, name ? (0, path_1.join)((0, path_1.dirname)(targetPath), name) : targetPath, ext === '.ts' || ext === '.tsx'

@@ -111,3 +95,17 @@ ? formatCode(content, 'typescript')

console.log(`Install ${chalk_1.default.yellow('Machinat')} framework and other dependencies...\n`);
const machinatDeps = getMachinatDependencies(platforms, recognizer);
const machinatDeps = [
'@machinat/core',
'@machinat/http',
'@machinat/dev-tools',
'@machinat/redis-state',
'@machinat/stream',
'@machinat/script',
platforms.includes('webview') ? '@machinat/webview' : undefined,
platforms.includes('messenger') ? '@machinat/messenger' : undefined,
platforms.includes('telegram') ? '@machinat/telegram' : undefined,
platforms.includes('line') ? '@machinat/line' : undefined,
recognizer === 'dialogflow' ? '@machinat/dialogflow' : undefined,
]
.filter((pkgName) => !!pkgName)
.map((pkgName) => `${pkgName}@${npmTag}`);
const npmInstallProcess = (0, child_process_1.spawn)('npm', ['install', ...machinatDeps], { cwd: projectPath, shell: true, stdio: 'inherit' });

@@ -114,0 +112,0 @@ const installCode = await thenifiedly_1.default.tillEvent('close', npmInstallProcess);

import { CreateAppContext } from '../../types';
declare const _default: ({ platforms, recognizer, projectName }: CreateAppContext) => string;
declare const _default: ({ platforms, recognizer }: CreateAppContext) => string;
export default _default;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("../../utils");
exports.default = ({ platforms, recognizer, projectName }) => `
exports.default = ({ platforms, recognizer }) => `
import Machinat from '@machinat/core';

@@ -6,0 +6,0 @@ import Http from '@machinat/http';${(0, utils_1.when)(platforms.includes('messenger')) `

@@ -69,3 +69,3 @@ "use strict";

nodemon.on('start', () => {
console.log(\`[dev:server] Dev server is running on \${PORT} port\`);
console.log(\`[dev:server] Dev server is running on localhost:\${PORT}\`);
});

@@ -72,0 +72,0 @@

import { CreateAppContext } from '../../../types';
export declare const mode = 509;
declare const _default: ({ platforms, recognizer }: CreateAppContext) => string;
declare const _default: ({ recognizer }: CreateAppContext) => string;
export default _default;

@@ -6,3 +6,3 @@ "use strict";

exports.mode = 0o775;
exports.default = ({ platforms, recognizer }) => `
exports.default = ({ recognizer }) => `
#!/usr/bin/env node

@@ -9,0 +9,0 @@ import { resolve as resolvePath } from 'path';${(0, utils_1.when)(recognizer === 'dialogflow') `

@@ -60,6 +60,2 @@ "use strict";

<title>Machinat Webview</title>
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/water.css@2/out/water.css"
/>
</Head>

@@ -66,0 +62,0 @@

{
"name": "@machinat/create-app",
"version": "0.5.1",
"version": "0.6.0-canary.0",
"author": "Patrick Liu <zeldalink0515@gmail.com> (https://github.com/lrills)",

@@ -38,3 +38,3 @@ "repository": {

},
"gitHead": "a1d71b2522984e14f3fc5bf9b50489ca081c895e"
"gitHead": "7db192f41dd48d19f382c6840163b366a8661c2c"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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