templates-mo
Version:
Templates is a scaffolding framework that makes code generation simple, dynamic, and reusable. Generate files, parts of your app, or whole project structures—without the repetitive copy-pasting
80 lines (79 loc) • 3.4 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.DEFAULT_TPS = exports.IS_TPS_INITIALIZED = exports.INIT_LOCAL_TPS_PATH = exports.INIT_LOCAL_PATH = exports.LOCAL_CONFIG_PATH = exports.LOCAL_PATH = exports.HAS_LOCAL = exports.GLOBAL_CONFIG_PATH = exports.GLOBAL_PATH = exports.TEMPLATE_SETTINGS_FILE = exports.TPS_FOLDER = exports.CONFIG_FILE = exports.MAIN_DIR = exports.CWD = exports.ORIGINAL_CWD = exports.USER_HOME = exports.IS_TESTING = void 0;
const os = __importStar(require("os"));
const path = __importStar(require("path"));
const fileSystem_1 = require("./fileSystem");
/**
* Environment
*/
exports.IS_TESTING = process.env.NODE_ENV === 'test';
exports.USER_HOME = os.homedir();
exports.ORIGINAL_CWD = process.cwd();
// TODO: well no longer need to do this when cli tests are changed to not use child process
exports.CWD = exports.IS_TESTING
? path.join(exports.ORIGINAL_CWD, '__tests__')
: exports.ORIGINAL_CWD;
exports.MAIN_DIR = path.resolve(__dirname, '../../');
/***************************
* Names
****************************/
exports.CONFIG_FILE = '.tpsrc';
exports.TPS_FOLDER = '.tps';
exports.TEMPLATE_SETTINGS_FILE = 'settings';
/***************************
* Setting and development
****************************/
/**
* global
*/
exports.GLOBAL_PATH = path.join(exports.USER_HOME, exports.TPS_FOLDER);
exports.GLOBAL_CONFIG_PATH = path.join(exports.GLOBAL_PATH, exports.CONFIG_FILE);
/**
* local
*/
const tpsLocal = (0, fileSystem_1.findUp)(exports.TPS_FOLDER, exports.CWD);
exports.HAS_LOCAL = tpsLocal && tpsLocal !== exports.GLOBAL_PATH;
/**
* LOCAL_PATH is any tps folder found in the parent directories
*/
exports.LOCAL_PATH = exports.HAS_LOCAL ? tpsLocal : null;
exports.LOCAL_CONFIG_PATH = exports.HAS_LOCAL
? path.join(exports.LOCAL_PATH, exports.CONFIG_FILE)
: null;
/***************************
* init
****************************/
/**
* path to initialize when calling `tps init`. its always is current working directory
*/
exports.INIT_LOCAL_PATH = path.normalize(exports.CWD);
/**
* path of tps folder if tps is initialized in repo
*/
exports.INIT_LOCAL_TPS_PATH = path.join(exports.INIT_LOCAL_PATH, exports.TPS_FOLDER);
exports.IS_TPS_INITIALIZED = (0, fileSystem_1.isDir)(exports.INIT_LOCAL_TPS_PATH);
exports.DEFAULT_TPS = `${exports.MAIN_DIR}/${exports.TPS_FOLDER}`;