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

appc-npm

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

appc-npm - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

.npmignore

149

index.js

@@ -1,1 +0,148 @@

exports.generate = require('lib/commands/generate');
var path = require('path');
var fs = require('fs-extra');
var async = require('async');
var _ = require('underscore');
module.exports = function (opts, callback) {
if (arguments.length === 1) {
callback = opts;
opts = {};
} else {
opts = opts || {};
}
var src = opts.src || process.cwd();
var type = opts.type;
var pkg = {};
var packagePath = path.join(src, 'package.json');
return async.series({
validate: function (next) {
if (!type) {
return next(new Error('Type is missing'));
}
if (!src) {
return next(new Error('Source is missing'));
}
try {
type = require(path.join(__dirname, 'lib', 'types', type));
} catch (e) {
return next(new Error('Unknown type: ' + type));
}
return fs.stat(src, function (err, stats) {
if (err) {
return next(new Error('Could not find source: ' + src));
}
if (!stats.isDirectory()) {
return next(new Error('Source is not a directory: ' + src));
}
return next();
});
},
copyInstaller: function (next) {
return fs.copy(path.join(__dirname, 'assets', 'appc-npm'), path.join(src, 'appc-npm'), function (err) {
if (err) {
return next(new Error('Failed to copy the installer'));
}
return next();
});
},
readPackage: function (next) {
return fs.exists(packagePath, function (exists) {
if (!exists) {
return next();
}
return fs.readJson(packagePath, function (err, json) {
if (err) {
return next(new Error('Failed to read package.json'));
}
pkg = json;
return next();
});
});
},
updatePackage: function (next) {
var mod;
return type.analyze(src, function (err, info) {
if (err) {
return next(err);
}
// don't overwrite...
_.defaults(pkg, info);
// only version, falling back to 1.0.0
pkg.version = info.version || pkg.version || '1.0.0';
// fallback for name
pkg.name = pkg.name || type.prefix + path.dirname(src);
if (typeof pkg.scripts !== 'object') {
pkg.scripts = {};
}
// don't overwrite postinstall
if (!pkg.scripts.postinstall) {
pkg.scripts.postinstall = 'node ./appc-npm';
}
return next();
});
},
writePackage: function (next) {
return fs.outputJson(packagePath, pkg, function (err) {
if (err) {
return next(new Error('Failed to write package.json'));
}
return next();
});
}
}, function (err) {
if (err) {
return callback(err);
}
return callback(null, pkg);
});
};

5

package.json
{
"name": "appc-npm",
"version": "1.0.0",
"version": "1.0.1",
"description": "Use NPM to distrbute Appcelerator Titanium, Alloy and Arrow components",

@@ -54,4 +54,5 @@ "main": "index.js",

"fs-extra": "^0.19.0",
"glob": "^5.0.10"
"glob": "^5.0.10",
"underscore": "^1.8.3"
}
}
# Appcelerator NPM Distribution
Package components for Appcelerator Titanium, Alloy and Arrow projects for distribition via NPM.
Package components for Appcelerator Titanium, Alloy and Arrow projects for distribution and dependencies via NPM.

@@ -10,8 +10,13 @@ ## Install

## Package
## Package & Publish
Simply navigate to your Titanium module or library, Alloy widget, sync adapter, Arrow connector or other component and run the CLI with the command for that component:
```
$ cd mywidget
$ appc-npm widget
+ alloy-widget-myWidget@1.0.0
$ npm publish
+ alloy-widget-myWidget@1.0.0
```

@@ -21,3 +26,3 @@

Create or update the `package.json` in your project:
Create or update the `package.json` for your project:

@@ -37,5 +42,10 @@ ```

$ npm install
> alloy-widget-myWidget@1.0.0 postinstall /Users/fokkezb/myProject/node_modules/alloy-widget-myWidget
> node ./appc-npm
alloy-widget-myWidget@1.0.0 node_modules/alloy-widget-myWidget
```
You'll find the widget in:
After which you'll find the widget in:

@@ -45,1 +55,53 @@ ```

```
## Nested dependencies
You can add dependencies to other Appcelerator dependencies on NPM to the `package.json` of your packaged component. So if your Alloy widget depends on a library, module or other widget then you can install them all in one go.
```
$ npm install
> alloy-widget-myWidget@1.0.0 postinstall /Users/fokkezb/myProject/node_modules/alloy-widget-myWidget
> node ./appc-npm
> ti-lib-xp.ui@1.0.0 postinstall /Users/fokkezb/myProject/node_modules/alloy-widget-myWidget/node_modules/ti-lib/xp.ui
> node ./appc-npm
alloy-widget-myWidget@1.0.0 node_modules/alloy-widget-myWidget
├── ti-lib-xp.ui@1.0.0
```
After which you'll find the widget and the lib it depends on in:
```
./app/widgets/myWidget
./app/lib/xp.ui.js
```
## Update
Run the command again to update the packaged installer, update the version (for components like Alloy widgets) and add missing files to copy.
```
$ appc-npm widget
+ alloy-widget-myWidget@1.0.1
```
## Commands/Types
You can use the following commands or types of components:
### DONE: `widget`
Alloy Widgets. Searches for `widget.json` to determine the base path and adds `controllers`, `views`, `styles`, `lib`, `assets` and `i18n` directories to the list of paths to copy to the project. The default package name is `alloy-widget-<id>` and the version is read from `widget.json` as well.
### TODO: `sync`
Alloy sync adapters. Searches for the first `.js` to determine the base path and adds that file to the list of paths to copy to the project. The default package name is `alloy-sync-<filename>` and version is `1.0.0`.
### TODO `lib`
Titanium, Alloy or Arrow CommonJS libraries. Searches for the first `.js` to determine the base path and adds that file to the list of paths to copy to the project. The default package name is `appc-lib-<filename>` and version is `1.0.0`.
### TODO: `module`
Titanium modules. Searches for the most recent ZIP file and adds that file to the `files` field of the `package.json` so that only that file and our installer will be published to NPM. It also reads the `manifest` to use in the default package, which is `ti-module-<id>`, and for the version.
### TODO: `block`
Arrow post or pre-blocks. Searches for the first `.js` to determine the base path and adds that file to the list of paths to copy to the project. The default package name is `arrow-block-<filename>` and version is `1.0.0`.
### TODO: `connector`
Arrow connectors. Searches for `appc.json` to determine the base path and adds that same directory to the list of paths to copy. The existing `package.json` is updated with the `postinstall` script and `appc-npm` property containing the list of paths.

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